Jump to content

Detecting an objects alpha to start/stop particle system


Oralbuddy
 Share

You are about to reply to a thread that has been inactive for 3645 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello, I am trying to adjust a script so that when the object its in (child prim of a linkset) is in a visible alpha state it activates the particle system in the script. I have found a script that does what I want but uses touch start/stop events instead. So I tried moddiying it to check changed events but i seem to have created a syntax error. any help would be appreciated.

 

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

//

// Simple Touch-based particle script.

//

// Use: Touching the prim containing this script will turn the particle system

// on and off.

//

//*************************************************************
ParticleStart()

{

llParticleSystem([

PSYS_PART_FLAGS, 291,

PSYS_SRC_PATTERN, 2,

PSYS_PART_START_ALPHA, 1.00,

PSYS_PART_END_ALPHA, 0.00,

PSYS_PART_START_COLOR, <1.00,1.00,1.00>,

PSYS_PART_END_COLOR, <1.00,1.00,1.00>,

PSYS_PART_START_SCALE, <0.25,0.25,0.00>,

PSYS_PART_END_SCALE, <1.00,1.00,0.00>,

PSYS_PART_MAX_AGE, 0.80,

PSYS_SRC_MAX_AGE, 0.00,

PSYS_SRC_ACCEL, <0.00,0.00,2.00>,

PSYS_SRC_ANGLE_BEGIN, 0.00,

PSYS_SRC_ANGLE_END, 1.05,

PSYS_SRC_BURST_PART_COUNT, 5,

PSYS_SRC_BURST_RADIUS, 0.10,

PSYS_SRC_BURST_RATE, 0.00,

PSYS_SRC_BURST_SPEED_MIN, 0.00,

PSYS_SRC_BURST_SPEED_MAX, 0.40,

PSYS_SRC_OMEGA, <0.00,0.00,0.00>,

PSYS_SRC_TEXTURE, "a96ecd50-96e1-28b4-51ec-96b3112210c0"

]);

}

ParticleStop()

{

llParticleSystem([]);

}

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

//

// Default state: LSL will always start in this state.

//

// Immediately go to the 'Off' state.

//

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

default
{
changed(integer change)
{float alpha = llGetLinkPrimitiveParams(LINK_THIS, [PRIM_COLOR,ALL_SIDES]);}
{if (float alpha = [0.0])
{ParticleStart();}
else
{ParticleStop();}
}
}

{

state_entry()

{

state Off;

}

}

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

//

// On state: Starts the particle system when this state is entered.

//

// Transitions to the 'Off' state when this prim is touched.

//

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

state On

{

state_entry()

{

ParticleStart();

}

touch_start(integer total_number)

{

state Off;

}

}

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

//

// Off state: Stops the particle system when this state is entered.

//

// Transitions to the 'On' state when this prim is touched.

//

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

state Off

{

state_entry()

{

ParticleStop();

}

touch_start(integer total_number)

{

state On;

}

}

Link to comment
Share on other sites

That's not the way a changed event works.  You have to test the change parameter against a bit mask to determine what has changed and then do whatever you wanted to.  In this case, you want to know if there has been a change in the object's color (which includes its alpha), so you need something like

	changed(integer change)	{		if(change & CHANGED_COLOR)		{			if(llGetAlpha(ALL_SIDES) == 0.0)			{				ParticleStart();			}			else			{				llParticleSystem([]);;			}		}	}

 Once you have determined that it's the color that has changed, then you are testing to see how it changed -- specifically, whether its alpha is now 0.0.  If so, then you trigger the particles.

BTW, don't bother writing a user-defined function for ParticleStop.  Just put the one-line command in the code.

Link to comment
Share on other sites

I may have misunderstood too, because I assumed that your script was in the root prim, which is where I would have put it.  In most cases, functions like this refer to the root of the linkset, since the face parameter doesn't make any sense if you are refering to the linkset as a whole.  Because your script is in the child prim, you will need to use llGetLinkPrimitiveParams.  That's not my main point, however.  The changed event won't work the way you wrote it.  You always need to test the change parameter against a bitmask  (in this case, CHANGED_COLOR) to determine what has changed.  Then you can go ahead and ask how much is has changed.

Link to comment
Share on other sites

ok I'm hearing you on the changed event. If im using  llGetLinkPrimitiveParams what is the syntax for this test? Hers my change as of yet still producing an error.

 

ParticleStart()

{

llParticleSystem([

PSYS_PART_FLAGS, 291,

PSYS_SRC_PATTERN, 2,

PSYS_PART_START_ALPHA, 1.00,

PSYS_PART_END_ALPHA, 0.00,

PSYS_PART_START_COLOR, <1.00,1.00,1.00>,

PSYS_PART_END_COLOR, <1.00,1.00,1.00>,

PSYS_PART_START_SCALE, <0.25,0.25,0.00>,

PSYS_PART_END_SCALE, <1.00,1.00,0.00>,

PSYS_PART_MAX_AGE, 0.80,

PSYS_SRC_MAX_AGE, 0.00,

PSYS_SRC_ACCEL, <0.00,0.00,2.00>,

PSYS_SRC_ANGLE_BEGIN, 0.00,

PSYS_SRC_ANGLE_END, 1.05,

PSYS_SRC_BURST_PART_COUNT, 5,

PSYS_SRC_BURST_RADIUS, 0.10,

PSYS_SRC_BURST_RATE, 0.00,

PSYS_SRC_BURST_SPEED_MIN, 0.00,

PSYS_SRC_BURST_SPEED_MAX, 0.40,

PSYS_SRC_OMEGA, <0.00,0.00,0.00>,

PSYS_SRC_TEXTURE, "a96ecd50-96e1-28b4-51ec-96b3112210c0"

]);

}
default
{
changed(integer change)
{
if(change & CHANGED_COLOR)
{
if(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_COLOR,ALL_SIDES]) == <255, 255, 255> 0.0)
{
ParticleStart();
}
else
{
llParticleSystem([]);
}
}
}
}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3645 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...