Don't click here unless you want to be banned.

LSL Wiki : state_entry

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org
state_entry()

The state_entry event occurs whenever a new state is entered, including script start/reset, and is always the first event handled.

This event is not invoked upon changing to the same state.

This event is not triggered every time the object is rezzed, due to the preservation of states between instances (rezes). Use on_rez for a reliable first event. It is also not called when the sim restarts.

Note: the LSL compiler doesn't recognise if there are two (or more) state_entry event handlers for the same state. Only the last state_entry is executed. And all the previous state_entry in the same state are ignored.

Compare with state_exit.


Events
Comments [Hide comments/form]
I am not 100% convinced of the following part: is always the first event handled.

I know for fact that I had a serious bug in one of my games that cost me several tens of thousands of Linden $ because a queued up event would get executed before state_entry.

To be specific, it was a guess a number between 1 and 10 game, after getting paid the bet it would move to the play state. The new random number was chosen in the state_entry of the play state. However if you clicked fast enough on the number that was it last time, you could get the link_message event to trigger before a new number was chosen.

I have not extensively tested this in the past 6 months though, so I don't know if this was changed or not.
-- AmaOmega (2004-02-24 18:50:16)
Ama, that bug might be gone, now that Cory has made the changes to event-state change code. (As of the version that changed how llListen was handled)
-- ChristopherOmega (2004-04-21 12:23:58)
the state_entry() of the deflut state is triggered when a script is reset or compiled.
-- KurtZidane (2005-12-19 17:00:31)
I have a problem. When I check/uncheck the "Running" box, state_entry is called only the first time after compile. Any more check/unchecks, the event is not called. Anyone have a work-around to detect if the script had just started running?

default
{
  state_entry()
  {
    llSay(0, "state_entry");
  }
}
-- DedricMauriac (2005-12-31 21:14:36)
Attach a comment to this page: