Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Right function, wrong state?

Bartiloux Desmoulins
Think Kink? Think Bart!
Join date: 27 Sep 2005
Posts: 121
11-21-2006 14:01
Is there some logical reason why you can set a variable equal to the local rotation in the Entry state? I don't want to do it in the default state. I'd like to get the rotation when the script initially fires up and then save that for the duration of all that the script may do. With it in the entry state, it won't compile. Please advise! Thank you.
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-21-2006 14:11
From: Bartiloux Desmoulins
Is there some logical reason why you can set a variable equal to the local rotation in the Entry state? I don't want to do it in the default state. I'd like to get the rotation when the script initially fires up and then save that for the duration of all that the script may do. With it in the entry state, it won't compile. Please advise! Thank you.


state_entry is an event, which is triggered from within a state, such as default. It gets triggered when the script enters the state in which you've put it. Any state can have a state_entry event, but the default one is the usual place to put it.

Incidentally, depending on what you're doing, you might want to do it in the on_rez event instead or as well as the state_entry.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-21-2006 14:21
Not sure what you mean by entry state but sounds like you are trying to call the llGetRot function outside of any state i.e.

CODE



rotation rot = llGetRot(); // this wont work!!!

default
{
}



This fails because initialisation values must be constants.
Bartiloux Desmoulins
Think Kink? Think Bart!
Join date: 27 Sep 2005
Posts: 121
Thank you
11-21-2006 15:07
That will teach me to rely on memory for info related to a post. The state_entry is actually in the default state, but that's where the compiler is complaining about the rotatation. I will try moving it to the on_rez event to see if that does the trick. Thank you for your help! -Bartiloux
Nynthan Folsom
Registered User
Join date: 29 Aug 2006
Posts: 70
12-01-2006 23:25
When a script starts up, or is reset, the first thing it does is receive a state_entry event. Unless you change to another state and then change back to the default state, the state_entry even in the default state will NOT be triggered again.

The on_rez event is NOT triggered when the script starts, but ONLY when you rez the object from inventory, or when it is rezzed from the contents of another prim via the llRezObject call.

If you want to get the local position of a prim once on start, and want it to remember this position even after being taken into inventory, put the llGetLocalPosition in the state_entry handler. Then never reset the script.

If you want to get the local position of a prim whenever you rez it, put the llGetLocalPosition in the on_rez handler.

If you want to get the local position whenever the script is started, OR the prim is rezzed, put the llGetLocalPosition call in the state_entry handler, and an llResetScript call in the on_rez handler. But NOTE that this will cause ALL global variables to be reset to the default state whenever the prim is rezzed.
Bartiloux Desmoulins
Think Kink? Think Bart!
Join date: 27 Sep 2005
Posts: 121
12-03-2006 10:23
Wow! Thanks for all the helpful info. I'm anxious to give it a shot! -Bart