|
Clintok Meyer
Registered User
Join date: 28 Apr 2006
Posts: 17
|
04-03-2007 07:47
Hi, Here's what I'm trying to do conceptually. Someone starts a demo by sitting on a pose ball. They hop off the pose ball. I'd like to reset the pose ball's script after they hop off because sometimes the next person sitting on it to test it has a problem. This doesn't happen every time but enough to be unpleasant. Could some kind person give me a snippet or point me at an example?  Also I'm trying to make something occur via script X seconds after someone exits a pose ball. I can communicate with another pose ball, the problem is starting a timer when someone exits a ball and then recognizing the timer event that would then trigger the communication to the other object. I'm unclear how to start and monitor a timer. Can someone assist with a little example code for that too pretty please?  Thank you very much /me making the world better, one hug at a time.
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
04-03-2007 08:10
There is code at the url below showing how to detect when someone sits or unsits: http://rpgstats.com/wiki/index.php?title=ChangedFor a timer, you can set an event like this: llSetTimerEvent(10.0); // For a 10 second event. And the event will trigger: timer() { llOwnerSay("Timer Triggered"); }
To unset a timer, use: llSetTimerEvent(0.0); Note that timers persist over state changes.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-03-2007 08:20
From: Clintok Meyer Hi, Here's what I'm trying to do conceptually. Someone starts a demo by sitting on a pose ball. They hop off the pose ball. I'd like to reset the pose ball's script after they hop off because sometimes the next person sitting on it to test it has a problem. This doesn't happen every time but enough to be unpleasant. Could some kind person give me a snippet or point me at an example?  Also I'm trying to make something occur via script X seconds after someone exits a pose ball. I can communicate with another pose ball, the problem is starting a timer when someone exits a ball and then recognizing the timer event that would then trigger the communication to the other object. I'm unclear how to start and monitor a timer. Can someone assist with a little example code for that too pretty please?  Thank you very much /me making the world better, one hug at a time. Use the changed event generated by the unsit to trigger a reset to the start conditions. You should already be monitoring this in order to stop the animation? The starting of a timer is by llSetTimerEvent(seconds) and will respond by raising a timer() event in your code a little while later. key agent = NULL_KEY; string animation = "animation name"; string text = "sit!"; vector offset = <0,0,1>;
default { state_entry() { llSetSitText(text); llSitTarget(offset,ZERO_ROTATION); }
changed(integer change) { if(change & CHANGED_LINK) //Is someone sitting? { key current_agent = llAvatarOnSitTarget(); if(current_agent != NULL_KEY) //Yes, someone is sitting. { agent = current_agent; llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION); } else //No one is sitting. { llStopAnimation(animation); // Reset stuff here agent = NULL_KEY;
llSetTimerEvent(5); } } }
run_time_permissions(integer perm) { agent = llAvatarOnSitTarget(); if(perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation("sit"); //Stop the default sit animation llStartAnimation(animation); } } timer() { llSetTimerEvent(0); // Do the rest of your Stuff Here }
on_rez(integer start_param) { llResetScript(); }
}
|
|
Clintok Meyer
Registered User
Join date: 28 Apr 2006
Posts: 17
|
04-03-2007 08:26
From: RJ Source There is code at the url below showing how to detect when someone sits or unsits: http://rpgstats.com/wiki/index.php?title=ChangedFor a timer, you can set an event like this: llSetTimerEvent(10.0); // For a 10 second event. And the event will trigger: timer() { llOwnerSay("Timer Triggered"); }
To unset a timer, use: llSetTimerEvent(0.0); Note that timers persist over state changes. Thank you kindly, I will try to use what you've posted. ..
|
|
Clintok Meyer
Registered User
Join date: 28 Apr 2006
Posts: 17
|
04-03-2007 08:28
From: Newgate Ludd Use the changed event generated by the unsit to trigger a reset to the start conditions. You should already be monitoring this in order to stop the animation? The starting of a timer is by llSetTimerEvent(seconds) and will respond by raising a timer() event in your code a little while later. key agent = NULL_KEY; string animation = "animation name"; string text = "sit!"; vector offset = <0,0,1>;
default { state_entry() { llSetSitText(text); llSitTarget(offset,ZERO_ROTATION); }
changed(integer change) { if(change & CHANGED_LINK) //Is someone sitting? { key current_agent = llAvatarOnSitTarget(); if(current_agent != NULL_KEY) //Yes, someone is sitting. { agent = current_agent; llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION); } else //No one is sitting. { llStopAnimation(animation); // Reset stuff here agent = NULL_KEY;
llSetTimerEvent(5); } } }
run_time_permissions(integer perm) { agent = llAvatarOnSitTarget(); if(perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation("sit"); //Stop the default sit animation llStartAnimation(animation); } } timer() { llSetTimerEvent(0); // Do the rest of your Stuff Here }
on_rez(integer start_param) { llResetScript(); }
}
Thank you too, I appreciate your post and will try to use what you've posted. ..
|