llRezObject timing
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-10-2007 08:33
Is this the correct sequence of events and what are the delays?
1. Main Object.Script1 llRezObject 2. Secondary Object rezzed 3. Secondary Object.Script2 handles on_rez event 4. Main Object.Script1 handles object_rez event. 5. Main Object.Script1 issues commands to Secondary Object
or is it
1. Main Object.Script1 llRezObject 2. Secondary Object rezzed 3. Main Object.Script1 handles object_rez event. 4. Secondary Object.Script2 handles on_rez event. 5. Main Object.Script1 issues commands to Secondary Object
or is it something else depending on sim performance?
I am trying to understand because something is occasionally going wrong in my game object.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-10-2007 08:58
At times the object_rez event may trigger before the object is actually rezzed. This is why we have suggested a few times that it is better to have the rezzed object send a message to the rezzer stating it is ready to recieve info.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-10-2007 09:07
From: Jesse Barnett At times the object_rez event may trigger before the object is actually rezzed. This is why we have suggested a few times that it is better to have the rezzed object send a message to the rezzer stating it is ready to recieve info. I appreciate the response. If I understand you correctly the rezzed object should send some form of message to the rezzor. If the rezzor object cannot proceed with its further actions before receiving the "I'm ready" message how do you stop it other than either using llSetScriptState or making the llRezObject the last thing it does before quiescing?
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-10-2007 09:23
Rezzer rezzes object and in the object_rezz event starts a listen with a handle (to remove the listen) set on a timer (to remove the listen if the object fails to rezz).
Rezzed object does a say stating "I am here" in the on_rez event and starts it's on listen for the rezzer.
Rezzer's listen event fires and it sends the data and then removes the listen.
Rezzed object recieves the info and removes it's listen.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-10-2007 11:26
From: Jesse Barnett Rezzer rezzes object and in the object_rezz event starts a listen with a handle (to remove the listen) set on a timer (to remove the listen if the object fails to rezz).
Rezzed object does a say stating "I am here" in the on_rez event and starts it's on listen for the rezzer.
Rezzer's listen event fires and it sends the data and then removes the listen.
Rezzed object recieves the info and removes it's listen. A very interesting approach. I will examine my code and see if it can be included. Thanks
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-13-2007 03:38
From: Jesse Barnett Rezzer rezzes object and in the object_rezz event starts a listen with a handle (to remove the listen) set on a timer (to remove the listen if the object fails to rezz).
Rezzed object does a say stating "I am here" in the on_rez event and starts it's on listen for the rezzer.
Rezzer's listen event fires and it sends the data and then removes the listen.
Rezzed object recieves the info and removes it's listen. Upon further reflection I cannot see a way to achieve my purpose. I have developed some simple scripts which I will display below. Create two boxes one red called "Red Box" and one blue called the "Blue Box". Put this script in the Blue Box vector Pos; integer Handle; integer Channel = 1234; Test1() { llOwnerSay("code line 1"); llOwnerSay("code line 2"); llRezObject("Blue Box",(Pos + < 0.0, 0.0, 1.0>),ZERO_VECTOR,ZERO_ROTATION,0); llSetTimerEvent(1.0); // llSleep(10.0); llOwnerSay("code line 3"); llOwnerSay("code line 4"); } default { state_entry() { llOwnerSay("Hello, Avatar!"); Pos = llGetPos(); } on_rez(integer start_param) { Pos = llGetPos(); }
object_rez(key id) { llOwnerSay("Object rez event raised."); }
touch_start(integer total_number) { llOwnerSay("Test1 started."); Test1(); }
timer() { llOwnerSay("Timer fired"); Handle = llListen(0, "", NULL_KEY, ""); llOwnerSay("Handle: " + (string)Handle); }
listen(integer channel, string name, key id, string message) { llOwnerSay("listen fired"); if (message = "Blue Box") { llListenRemove(Handle); llOwnerSay("Handle: " + (string)Handle); llSetTimerEvent(0.0); llOwnerSay("Timer set to 0.0"); } } }
put the Blue Box into the Red Box and add the script integer sparm; default { state_entry() { llOwnerSay("This is the rezzed object."); }
on_rez(integer start_param) { sparm = start_param; llOwnerSay("on_rez fired"); llWhisper(start_param,"Blue Box"); }
touch_start(integer total_number) { llOwnerSay("Rezzed object touched"); llWhisper(sparm,"Blue Box"); } }
When the Red Box is rezzed and touched it starts Test1 which displays code line 1 and code line 2 then rezzes the Blue Box above it. the llOwnerSay's indicate that the Listen event is never honoured or have I got it wrong. Be prepared to reset the red box script as the timer will continue to fire. What I want to happen is when touched the Red Box executes code line 1 and code line 2 then rezzes the Blue Box then waits for the message to come back from the Blue Box and then and only then execute code line 3 and code line 4.
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
11-13-2007 09:22
This doesn't seem quite right to me, but I haven't studied it that carefully.
Move Line 3 and 4 to their own function, F(). In Test1(), setup the listener.
When yoiu hear the whisper, call F.
the purpose of the timer is to clean up if things go wrong. Taht is, after say 10 seconds, decide that the blue box is not going to report in, and repair the damage or bail out.
lee
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-13-2007 09:43
I am at work so don't have time to tweak yours but here is an example I did the other day: integer sphere_listen; integer sphere_chan; key sphere_key; string sphere; float listen_timer = 60.0;
random_chan() { do { sphere_chan = ((integer) llFrand(3) - 1) * ((integer) llFrand(-9999000)); } while(sphere_chan > -100000); }
default { state_entry() { sphere = llGetObjectName(); }
touch_start(integer total_number) { state rezzer; }
on_rez(integer start_param) { sphere_key = llGetKey(); llAllowInventoryDrop(TRUE); sphere_chan = llGetStartParameter(); llSay(sphere_chan, (string)sphere_key); llSay(sphere_chan,"GIMME"); }
changed(integer change) { if(change && CHANGED_INVENTORY) { llSay(sphere_chan, "RCVD"); } } }
state rezzer { state_entry() { random_chan();//create a new channel to listen on llSetTimerEvent(listen_timer); if(sphere == "Blue Sphere") { sphere_listen = llListen(sphere_chan,"Red Sphere", NULL_KEY, ""); llRezObject("Red Sphere", llGetPos()+<1,0,0>,ZERO_VECTOR,ZERO_ROTATION,sphere_chan); } else if(sphere == "Red Sphere") { sphere_listen = llListen(sphere_chan,"Blue Sphere", NULL_KEY, ""); llRezObject("Blue Sphere", llGetPos()+<1,0,0>,ZERO_VECTOR,ZERO_ROTATION,sphere_chan); } } listen(integer channel, string name, key id, string message) { if(message == "GIMME") { llGiveInventory(sphere_key, "Blue Sphere"); llGiveInventory(sphere_key, "Red Sphere"); } else if(message == "RCVD") { llDie(); } else { sphere_key = (key)message; } } timer() { llListenRemove(sphere_listen); llSetTimerEvent(0.0); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-13-2007 11:45
From: Lee Ponzu This doesn't seem quite right to me, but I haven't studied it that carefully.
Move Line 3 and 4 to their own function, F(). In Test1(), setup the listener.
When yoiu hear the whisper, call F.
the purpose of the timer is to clean up if things go wrong. Taht is, after say 10 seconds, decide that the blue box is not going to report in, and repair the damage or bail out.
lee I believe I have found a method after your reply. It does work if you put a llSleep of 2 seconds into the blue box between the llOwnerSay("on_rez fired"  ; and the llWhisper(0,"Blue Box"  ; This cures the problem of the listen not being received but needs your suggestion to be able to continue correctly with code line 3 and code line 4 in a new function called as you say. Many thanks for your contribution to my understanding this crazy system. However the delay would mean an additional 2 seconds every time I use the method and it can be used up to 15 times for each move from the player. Once or twice could be tolerated but 30 seconds forget it too long. So I am still looking for a solution which bypasses the inherent problems with the llSetScriptState method. If only you could preserve the status I might get this thing to work reliably.
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-13-2007 11:50
From: Jesse Barnett I am at work so don't have time to tweak yours but here is an example I did the other day: SNIPPED FOR BREVITY END OF SNIP
I think there is a problem here Jesse. The problem is not getting the thing to work but get it to continue to process the code lines 3 and 4. See suggestion above. I can get the Red Sphere to rez a Blue Sphere but don't see how that solves my problem. Can you, when you have time, explain in a little more detail. Thanks for taking the time from work to think about it.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-13-2007 17:38
Red Box Script: vector pos; integer Handle; integer Channel = 1234; Test1() { llOwnerSay("code line 1"); llOwnerSay("code line 2"); llRezObject("Blue Box",(pos + < 0.0, 0.0, 1.0>),ZERO_VECTOR,ZERO_ROTATION,Channel); } default { touch_start(integer total_number) { pos = llGetPos(); llOwnerSay("Test1 started."); Handle = llListen(Channel, "", NULL_KEY, ""); llSetTimerEvent(20.0);//all this timer is for is in case the object doesn't rez Test1(); }
timer() { llListenRemove(Handle); llSetTimerEvent(0.0); }
listen(integer channel, string name, key id, string message) { llOwnerSay("listen fired"); if (message == "Blue Box") { llOwnerSay("code line 3"); llOwnerSay("code line 4"); llSetTimerEvent(0.0); llOwnerSay("Timer set to 0.0"); } } }
Blue Box Script: default { on_rez(integer start_param) { llWhisper(start_param,"Blue Box"); llOwnerSay((string)start_param); } }
Hang in there and you will get it. Eventually you start to get how the work flows through the script. Red Prim: touch_start starts the timer and triggers Test1; Test1 does the 1st two llSays and rezzes "Blue Box" and the channel is passed in the start parameter. Then the script waits for the message from the blue prim. >>>>>>>>>>>>>>>>>>>>>>>>>>>> Blue Prim: Recieves start parameter and uses it as the channel to say "Blue Box" >>>>>>>>>>>>>>>>>>>>>>>>>>>>> Red Prim: Now hears "Blue Box", llSays next two messages, sets timer to zero. timer() removes the listen. If "Blue Box" never rezzes and message is never recieved then the llSetTimerEvent reaches 0 and triggers timer() and still removes listen. PS, You will also notice that when coded correctly there is no need to use llSleep anywhere in the scripts.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-14-2007 08:11
Many many thanks for the scripts. I think I understand it. Essentially by moving the further code lines to the listen event (only to be executed when the rezzed object sends a reply that it has rezzed) allows the object_rez to be the last thing in the script before it quiesces and thus the state of the script is known (waiting for an event). Clever. Now I have got to implement it.
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-15-2007 02:16
One further thought: Should there not be a llListenRemove(Handle) in the listen event that recognises the message from the rezzed object?
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-15-2007 03:57
From: Gregory McLeod One further thought: Should there not be a llListenRemove(Handle) in the listen event that recognises the message from the rezzed object? Setting a timer event to 0 makes the script process everything in the timer. In this case the timer is removing the listen handle.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-15-2007 08:11
Thanks. I hadn't known that but, when you mention it, it seems obvious. I suppose that is the way of things.
|
|
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
|
11-16-2007 01:00
All satisfactorily implemented. Thanks to all who contributed to my better understanding.
|