Forseti Svarog
ESC
Join date: 2 Nov 2004
Posts: 1,730
|
11-30-2005 06:52
(beginner level scripter here) I'm trying to do a very simple touch event which link-messages a particle script on and off. What I don't get is why it works sometimes and not others. When it fails, I can actually see it **trying** to trigger... i.e. the particles start, but then they immediately stop. It's as if I clicked twice in super-rapid succession rather than once. I'll post the script skeletons in here and if anyone knows what's going on, your help is much appreciated. script in parent prim // ON-OFF PARENT PRIM SCRIPT integer gToggle;
default { state_entry() { }
touch(integer total_number) { if (!gToggle) { gToggle=1; } else if(gToggle) { gToggle=0; }
llMessageLinked(LINK_ALL_OTHERS, gToggle, "", ""); } }
And then the script in the child particle prim // PARTICLE SCRIPT default { state_entry() { updateParticles(1); } link_message(integer sender_num, integer num, string str, key id) { updateParticles(num); } }
updateParticles(integer num) {
if (!num) llParticleSystem([]); else llParticleSystem([ PSYS_PART_MAX_AGE,age, // CUT SHORT THE PARTICLE SCRIPT FOR BREVITY
|
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
|
11-30-2005 07:25
I thing that your touch event is being called a second time, and switching everything off right after it was switched on. (touch is called repeatedly as long as the object is being touched.) Try using touch_start instead - it will only be called once per touch - which should do the trick.
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-30-2005 08:15
Also I'd compress the contents of your touch into: llMessageLinked(LINK_ALL_OTHERS, (gToggle = !gToggle), "", ""); Just a bit more compact =)
|
Forseti Svarog
ESC
Join date: 2 Nov 2004
Posts: 1,730
|
11-30-2005 10:28
thanks guys. touch_start seems to work.
i avoided it cause i coulda sworn someone told me once that it was laggy... like it would start doing updates on it's own (you could press ctrl-shift-alt-u and watch the pulses go even when no one was touching)
but maybe that got translated poorly into my head. This works so I'm going to use it!
|