|
Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
|
06-12-2007 09:07
I'm making a beverage server. I've got a parent script in the root prim that responds to Touch - it sends Linked message to one of child prims to become visible, as well as delivering a beverage to the Toucher. And this is working fine to bring the child prim to visible on the Touch event and deliver the drink. What I need to finish this is to (without using Touch again, since that would deliver another beverage), know how to trigger the parent script to send a Linked Message after a second or two of 'okay now reset yourself and go back to your default state.. which is full alpha, for the child prim'. Do I need some kind of timer event thingy? Here's my parent: integer ON = FALSE;
flow_on() { llMessageLinked(LINK_SET, 69, "flowon", NULL_KEY); }
flow_off() { llMessageLinked(LINK_SET, 69, "flowoff", NULL_KEY); }
update_flow() { if( ON ) { flow_on(); } else { flow_off(); } }
default {
touch_start(integer total_number) { llMessageLinked(LINK_SET, 69, "flowon", NULL_KEY); llGiveInventory(llDetectedKey(0), "Coffee");
}
}
and my child : init() { llSetAlpha(0.0, ALL_SIDES);
}
default { state_entry() { init(); } on_rez( integer p) { llResetScript(); }
link_message(integer sender, integer channel, string m, key id) { if (m == "flowon") { llSetAlpha(1.0, ALL_SIDES); } if (m == "flowoff") { llSetAlpha(0.0, ALL_SIDES); } } }
Thanks for any assistance!
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
06-12-2007 09:15
Yes you need a "timer event thingy". llSetTimerEvent(float seconds) will trigger the timer() event after seconds. note that it will CONTINUE to trigger timer events until you turn off the "timer event thingy": llSetTimerEvent(0.0); Which you could do in your timer event to keep it from firing a second time. I.e: touch_start(integer total_number) { llMessageLinked(LINK_SET, 69, "flowon", NULL_KEY); llGiveInventory(llDetectedKey(0), "Coffee"); llSetTimerEvent(3.0); // 3 seconds
} timer() { llSetTimerEvent(0.0); // turn off timer llMessageLinked(LINK_SET, 69, "flowoff", NULL_KEY); } [/php]
|
|
Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
|
06-12-2007 09:22
Thanks RJ! I'll noodle around with that 
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
06-12-2007 09:37
Simplest version for your parent: default { touch_start(integer num) { llMessageLinked(LINK_SET, 69, "flowon", NULL_KEY); while (num-- > 0) llGiveInventory(llDetectedKey(num), "Coffee"  ; llSleep(2.0); // chill for 2 seconds llMessageLinked(LINK_SET, 69, "flowoff", NULL_KEY); } } This will make it sluggish if you have a lot of people clicking at once because it won't respond to any other clicks during the sleep, if that's not acceptable then you can use the timer version.
|
|
Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
|
06-12-2007 12:44
Thanks Boss for the extra method.
First one worked great, thanks again RJ!
|