|
Sharon Ewry
Registered User
Join date: 30 Nov 2006
Posts: 33
|
03-21-2007 07:55
can the link_message be used inside a loop? just been trying to create a script to count to a number by loop.. that i can do easy.. but i want to be able to push a button on a prim to stop it counting at any time. I know how to get the message across from the button no problem but i don't seem to be able to get it to work when in a loop grrrrr Anything i should know that isn't explained anywhere as i have don't seem to be able to find anything on this? even a simple little script i could look at to trigger of my now dead brain sells would help Thanks peeps Shaz x
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-21-2007 08:07
From: Sharon Ewry can the link_message be used inside a loop? just been trying to create a script to count to a number by loop.. that i can do easy.. but i want to be able to push a button on a prim to stop it counting at any time. I know how to get the message across from the button no problem but i don't seem to be able to get it to work when in a loop grrrrr Anything i should know that isn't explained anywhere as i have don't seem to be able to find anything on this? even a simple little script i could look my trigger of my now dead brain sells  Thanks peeps Shaz x Link message is an event handler so no it cannot be used in a loop as it is an INPUT to the system. Your best bet is to use a timer. integer STOPCOUNTING = 9999; integer counter = 0;
default { state_entry() { llSetTimerEvent(1);} // once per second timer
timer() { ++counter; llSetText((string)counter, <1,1,1>,1); }
link_message(integer sender_num, integer num, string str, key id) { if(STOPCOUNTING == num) llSetTimerEvent(0); } }
Another apporach would be to stop the script using llSetScriptState from an external script.
|
|
Sharon Ewry
Registered User
Join date: 30 Nov 2006
Posts: 33
|
03-21-2007 08:16
From: Newgate Ludd Link message is an event handler so no it cannot be used in a loop as it is an INPUT to the system. Your best bet is to use a timer. integer STOPCOUNTING = 9999; integer counter = 0; default { state_entry() { llSetTimerEvent(1);} // once per second timer timer() { ++counter; llSetText((string)counter, <1,1,1>,1); } link_message(integer sender_num, integer num, string str, key id) { if(STOPCOUNTING == num) llSetTimerEvent(0); } }
Another apporach would be to stop the script using llSetScriptState from an external script. ohhhhh thats why it wouldn't work then  ) I think the first idea would be better with the timer as i wouldn't want the script to stop as it has other things to do once its done counting. So i timer event it is then hehe Thanks loads for that, all makes sense now Shaz x
|