Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

help on/off via touch

Roach Keegan
Registered User
Join date: 26 Apr 2004
Posts: 14
01-09-2006 13:07
i have the following script wich ive peiced together from some existing scripts to work with particles made via the particle factory(particle generator) and i was wondering if somone could offer some assistance converting this to touch activated on/off rather than a listen

default
{
state_entry()
{
llListen(0,"",NULL_KEY,"";);
}

listen(integer number, string name, key id, string m)
{
if (m=="on";)
{
llSay(1,"";);
llParticleSystem([7,2.0,0,291,6,<0.01,0.01,0.0>,9,2,13,0.05,15,15,16,0.08,17,0.01,18,0.01,12,"67de84bc-8eb2-448b-3121-574a8a0e2708"]);

}
else if (m=="off";)
{
llSay(1,"";);
llParticleSystem([]);
}
}
}
Deneria Sholokhov
Leaf on the Wind
Join date: 25 Oct 2005
Posts: 12
01-09-2006 15:00
Sure, wrap your existing code int the touch block instead of the listen block, then declare your m var as a global integer and set it to false. your if statements should check if the m var is true or false and do the worke...IE: on first touch, m will be false, so you turn on the particle system, and them make m = TRUE, when you touch again, m will be true, and that if block can turn off your particle system, after that, you set m = FALSE again and everything will do what you need.

Pretty simple, and the reason I didn't just write the code for you is that this little excercise will help you understand the scripts better.

look up touch, and integer and if in LSLWiki for more information on how to do this.

PM me with your altered code if you get stuck.
Micheal Richard
Expat in Tokyo
Join date: 28 Sep 2005
Posts: 6
Simple touch state
01-10-2006 05:05
Here is your script again but in a touch state that uses an interger for the on/off condition. The integer "on" does go before the default state. Have fun :-)
---------------- Start script ----------------
integer on = TRUE;

default
{
touch_start(integer iNum)
{
if (!on) llParticleSystem([7,2.0,0,291,6,<0.01,0.01,0.0>,9,2,13,0.05,15,15,16,0.08,17,0.01,18,0.01,12,"67de84bc-8eb2-448b-3121-574a8a0e2708"]);
else llParticleSystem([]);
on = !on;
}
}
---------------- End script ----------------

Note: Some people learn by example. So once you get this script to work try modifying it... Like with a listen channel for linked objects, More than just two conditions ( on, off, low, medium, etc), etc.
Roach Keegan
Registered User
Join date: 26 Apr 2004
Posts: 14
01-11-2006 20:00
thank you , ill try messing with it some.