Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Particle script that emits random textures?

Rubina Stanwell
Queen of Sheeba
Join date: 14 Jun 2006
Posts: 128
12-10-2006 14:48
hiya :)

my first post in the scripting section i feel like the new kid on the first day of highschool, lolololol.

We're using the Ama Omega particle system template and were just wondering how we would go about editing/adding to it so that it emits random textures that we choose?
_____________________
Stealing hearts and panties since the eighties...
---------------------------

http://adimusl.wordpress.com | Afrocentric Hairstyles for Men & Women in SecondLife
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
12-10-2006 15:52
Each time you call llParticleSystem, you specify one texture to emit particles consisting thereof. If you want to randomly change textures, you have to change them over time and re-call llParticleSystem with a different texture, selected randomly from a list, for example.

You'll probably have to make a list of texture names or keys, set up a timer() event (using llSetTimerEvent()), and then use the llFrand() function to select one of the textures from the list.
LizardTongue Surface
Registered User
Join date: 31 May 2005
Posts: 11
12-24-2006 05:14
if you want a truely random pick try this:

PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE,(integer)llFrand((float)llGetInventoryNumber(INVENTORY_TEXTURE)))

I set up the above in the llParticleSystem call itself (using Ama Omega engine modified by Jopsy Pendragon and further modified by me)

you'll still need the timer event to restart the particle system so as to change textures but no list making; just drop the textures in the prim content tab (not the texture tab) and let the prim manage the list for you automaticaly

this also allows you to add and remove textures on the fly as the script is running without haveing to rebuild the list yourself

and it's fast as all it needs is the count of textures then it picks a random number in that range and uses that texture

BONUS: less overhead on the server since there is no script handleing of lists

Laters,
Lizardtongue Surface
Dragonlady Boa
Registered User
Join date: 13 Jul 2007
Posts: 18
07-25-2007 06:48
I think this is what I'm looking for. Although, i must admit, I am totally LOST as to what was said. Ive not used timers yer. And am just learning scripting and it's driving me nuts. is there perchance a sample, or teaching script you can put up. And can this be trigger worded. if so, how?
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
07-25-2007 07:52
The basic concept is as follows. Obviously you'll need to add contols for setting it off etc but...(of course all my neat formatting is going to be lost as soon as I click 'Submit'!)

From: someone
//**********************************************

PopulateParticleParameters()
{
//populate all particle parameters, including PSYS_SRC_TEXTURE

ParticleAge = //populate the particle age for PSYS_PART_MAX_AGE
StartColour = //populate the start colour for PSYS_PART_START_COLOR
etc
etc
Texture = //populate the texture used on first iteration for PSYS_SRC_TEXTURE

}

//**********************************************

ChooseDifferentTexture()
{
//code for changing PSYS_SRC_TEXTURE goes here

Texture = //whatever mechanism you choose to employ to populate PSYS_SRC_TEXTURE on subsequent iterations
}

//**********************************************
list UpdateParticleParameters()
{

return ([ PSYS_PART_MAX_AGE,ParticleAge,
PSYS_PART_FLAGS,ParticleFlags,
PSYS_PART_START_COLOR, StartColour,
PSYS_PART_END_COLOR, EndColour,
PSYS_PART_START_SCALE,StartSize,
PSYS_PART_END_SCALE,EndSize,
PSYS_SRC_PATTERN, pattern,
PSYS_SRC_BURST_RATE,ParticleRate,
PSYS_SRC_ACCEL, AccelPush,
PSYS_SRC_BURST_PART_COUNT,ParticleCount,
PSYS_SRC_BURST_RADIUS,StartRadius,
PSYS_SRC_BURST_SPEED_MIN,MinSpeed,
PSYS_SRC_BURST_SPEED_MAX,MaxSpeed,
PSYS_SRC_TARGET_KEY,Target,
PSYS_SRC_ANGLE_BEGIN,AngleBegin,
PSYS_SRC_ANGLE_END,AngleEnd,
PSYS_SRC_OMEGA, EmitterOmega,
PSYS_SRC_MAX_AGE, SystemLife,
PSYS_SRC_TEXTURE, Texture,
PSYS_PART_START_ALPHA, StartAlpha,
PSYS_PART_END_ALPHA, EndAlpha
]);
}

//***************************************

default
{
state_entry()
{
//immediate first iteration
PopulateParticleParameters();
UpdateParticleParameters();
llParticleSystem(UpdateParticleParameters);
llSetTimerEvent(0.05);
}


timer()
{
//subsequent iterations choose a different texture
ChooseDifferentTexture();
UpdateParticleParameters();
llParticleSystem(UpdateParticleParameters);
}

// default end bracket
}


NB: in the above example the "UpdateParticleParameters();" and "llParticleSystem(UpdateParticleParameters);" calls within state_event() are not really necessary, because llSetTimerEvent() has been set to trigger Timer() event so quickly.

However, if llSetTimerEvent() had been set to a longer time, say 20 or 30 seconds, you might want to do an iteration before llSetTimerEvent() kicks-in. It is therefore included for illustrative purposes

XxX