Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to Force Script to Reset on Rez

Lief Rush
Registered User
Join date: 15 Dec 2006
Posts: 18
11-18-2008 09:46
OK... I see the next thread discuss's this as a mono related issue.. But I have gone both mono and no mono and am clearly missing something fundamental...

I can make the script work fine, and then when I take the object in to inventory and Re Rez and it does not reset the script on each new Rez.. Mono doesnt seem to be a factor..

What am I not understanding about on_rez and Reseting scripts ? Based on the output from this script, it seems to me that the on_rez isn't even being processed as the Hello from that area is never seen??????

I really think I must be doing something wrong?????

Code Below
___________________________________________
default
{

on_rez(integer start_param)
{llSay(0,"Hello from On Rez Area of Script";);llResetScript();}


state_entry()
{llSay(0, "Hello,From State Entry in the default area of the script";);state confusion;}


}
state confusion
{

state_entry()
{llSay(0, "Hello,from the State Entry in the State of Confusion area";);}


touch_start(integer total_number)
{llSay(0, "This is the touch start Event on the State of Confusion";);}
}


______________________________________________
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
11-18-2008 09:50
Your state confusion does not have an on_rez event handler. Only event handlers in the current state are called.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
11-18-2008 09:51
Try also putting an on_rez in your confusion state... To reset a script when it gets rezzed, you'd just do something like:

on_rez (integer param) { llResetScript(); }
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Atom Burma
Registered User
Join date: 30 May 2006
Posts: 685
11-18-2008 09:52
if you can, try another parcel to test your scripts. i just had a crazy week long lag fest that almost wiped out my sim. was largely my fault, but when land loses its timing the scripts are generally the first to go. I couldn't even get a simple lslDialogue to run last night. It could be the land you are on, just a possability.
Lief Rush
Registered User
Join date: 15 Dec 2006
Posts: 18
11-18-2008 09:58
I see you guys mention the State Change.. I thought the On_Rez in Default state would be processed before the state change since it is the first thing in default to be addressed?? This may be my misunderstanding then??

I think that because the data does in fact process the hello from the State Entry area of the default state. Also the call to the state of confusion is from inside the default state.

Also if I did the Reset from within the State of Confusion, wouldn't that reset any variables I had changed before the reset?? Not good if I am passing data into the script that I want it to remember later..?? Hope I am makingsense...
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
11-18-2008 10:06
From: Lief Rush
I see you guys mention the State Change.. I thought the On_Rez in Default state would be processed before the state change since it is the first thing in default to be addressed?? This may be my misunderstanding then??

But when you take the object into inventory, and when you drag it back in-world, it's still in the confusion state..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Lief Rush
Registered User
Join date: 15 Dec 2006
Posts: 18
11-18-2008 10:08
OK.. so I add the on_rez to the State of Confusion and it does see it at Rez, but never does it see on_rez in the Default area????????

I guess I just learned something.. THANKS!!
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
11-18-2008 10:10
From: Lief Rush
I see you guys mention the State Change.. I thought the On_Rez in Default state would be processed before the state change since it is the first thing in default to be addressed?? This may be my misunderstanding then??


Resetting a script restores it to default state, but re-rezzing a scripted object DOESN'T. The object will be rezzed in the same state it was originally in. If it's in the "confusion" state, it won't do anything on rez, because the confusion state has no on_rez event. (States don't "inherit" or "override" in LSL - if the script is in state confusion, everything in every other state - including default - is ignored. This can be slightly misleading - remember that "default" refers to "here are the event handlers in my default state.."; it does NOT mean "here are my default event handlers..";)

From: someone

I think that because the data does in fact process the hello from the State Entry area of the default state. Also the call to the state of confusion is from inside the default state.


When the script is reset, it is set back to default state, so the state_entry of the default state runs.

From: someone

Also if I did the Reset from within the State of Confusion, wouldn't that reset any variables I had changed before the reset?? Not good if I am passing data into the script that I want it to remember later..?? Hope I am makingsense...


A reset will indeed reset any variables you have changed, no matter which state you are in at the time you do the reset.
Lief Rush
Registered User
Join date: 15 Dec 2006
Posts: 18
11-18-2008 10:10
From: Meade Paravane
But when you take the object into inventory, and when you drag it back in-world, it's still in the confusion state..



Ok... now this makes sense to me.. so the only way to CYA is to put a Reset Script in every state so if the object gets dragged away in alt state, it will all reset... THANKS AGAIN!!
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
11-18-2008 12:55
Not the ONLY way. An alternative is to design it so you don't need to reset when you rez. Instead you just continue from where you left off.
_____________________
So many monkeys, so little Shakespeare.