Hiyas Everyone,
I have been adding the following code to my scripts:
on_rez (integer start_param)
{
llResetScript();
}
Has anything changed to where this would not be necessary anymore?
Thanx!
These forums are CLOSED. Please visit the new forums HERE
On_Rez - llResetScript |
|
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
01-23-2008 06:39
Hiyas Everyone,
I have been adding the following code to my scripts: on_rez (integer start_param) { llResetScript(); } Has anything changed to where this would not be necessary anymore? Thanx! |
|
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
|
01-23-2008 06:40
nothing has changed... A script will not reset unless you tell it to..
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
01-23-2008 06:56
It's not ever been really _necessary_...
That said, I do do it frequently on objects that don't have a big start-up cost just because it seems like an easy/cheap way to clean things up and sorta start fresh. For something that does have a lot of start-up cost, like maybe something that reads in a notecard config or does other asset/database things, I'd think twice before doing that.. _____________________
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 |
|
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
|
01-23-2008 07:05
The main reason most people include that code in their scripts, is that they want to be able to test the script while working on it but also know that it will work properly for end users.
The problem is that scripts have essentially two "entry points" - state_entry() and on_rez(). When you "save" a script, state_entry() runs, but on_rez() doesn't, and the script starts from a fresh state. When one of your customers rezzes your object, on_rez() runs, but state_entry() doesn't, and the state is not fresh. The code above basically ensures that the script starts from state_entry() in a fresh state no matter which of these happened. It's appropriate for some scripts but not for others (and it wasn't ever a bug, so it isn't likely that "something will change so it won't be necessary" . |
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
01-23-2008 08:21
Okies... thanks everyone. I dunno where I picked it up but I always had the distinct impression that there was a bug and that this was a necessary hack. Fortunately, I do prefer that all (so far) of my scripts start from a refreshed state. Thanx again!
![]() |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-23-2008 19:41
if the script isn't storing any data, or relying on one time defaults in the start up (like llGetOwner) it isn't usually necessary...
if llGetOwner is the only problem, it's easy enough to reset it in the changed event on new owners, or if llGetOwner is being stored, just restore it on owner changed. _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |