Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Random texture selection for Particle emitter

OhMy Shalala
Registered User
Join date: 16 Sep 2006
Posts: 15
05-31-2009 06:36
I have this script and need to put in a way for the script to grab a random texture from the inventory for each emission, OR to use a list of the textures in inventory for it to cycle through for each emission. Hope someone can help me. Here is the script:


default {
state_entry() {
llParticleSystem(
[
// texture parameters:
PSYS_SRC_TEXTURE , "",
PSYS_PART_START_SCALE , <1.00000, 1.00000, 0.00000>, PSYS_PART_END_SCALE , <1.00000, 1.00000, 0.00000>,
PSYS_PART_START_COLOR , <1.00000, 1.00000, 1.00000>, PSYS_PART_END_COLOR , <1.00000, 1.00000, 1.00000>,
PSYS_PART_START_ALPHA , (float)1.000000, PSYS_PART_END_ALPHA , (float)1.000000,
// production parameters:
PSYS_SRC_BURST_PART_COUNT , 1,
PSYS_SRC_BURST_RATE , (float)0.340000,
PSYS_PART_MAX_AGE , (float)2.390000,
PSYS_SRC_MAX_AGE , (float)0.000000,
// placement parameters:
PSYS_SRC_PATTERN , 4,
PSYS_SRC_BURST_SPEED_MIN , (float)0.744597, PSYS_SRC_BURST_SPEED_MAX , (float)0.744597,
PSYS_SRC_BURST_RADIUS , (float)0.000000,
// placement parameters (for angles only):
PSYS_SRC_ANGLE_BEGIN , (float)0.392024,
PSYS_SRC_ANGLE_END , (float)0.000000,
PSYS_SRC_OMEGA , <0.00000, 0.00000, 0.00000>,
// after-effects & influences:
PSYS_SRC_ACCEL , <0.00000, 0.00000, 0.00000>,
PSYS_SRC_TARGET_KEY , (key)"",
PSYS_PART_FLAGS , ( 0 // texture & influence options:
// | PSYS_PART_INTERP_COLOR_MASK
// | PSYS_PART_INTERP_SCALE_MASK
// | PSYS_PART_BOUNCE_MASK
// | PSYS_PART_WIND_MASK
// | PSYS_PART_FOLLOW_SRC_MASK
// | PSYS_PART_FOLLOW_VELOCITY_MASK
// | PSYS_PART_TARGET_POS_MASK
// | PSYS_PART_TARGET_LINEAR_MASK
| PSYS_PART_EMISSIVE_MASK
)] );
}
}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
05-31-2009 09:23
In state_entry, but before the llParticleSystem call, put something like this ....

CODE

integer num = llGetInventoryNumber(INVENTORY_TEXTURE);
string textureName = llGetInventoryName(INVENTORY_TEXTURE,(integer)llFrand(num-1));


then change the first texture parameter to read

PSYS_SRC_TEXTURE , textureName,

Doing this in state_entry, of course, will only change the particle texture each time you reset the script, and your partcle emitter will also always be ON, since you haven't provided any triggering device to switch it on and off. Unless that's what you want to do, you ought to consider moving all of this code into another event (touch_start, listen, collision, sensor,.... whatever) and providing some sort of switch.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at