11.07.2015 Views

Linden Scripting Language Guide - Engineering Center

Linden Scripting Language Guide - Engineering Center

Linden Scripting Language Guide - Engineering Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5. StatesWarningIt is a common mistake to assume that the state_entry() callback is called when you rez an object outof your inventory. When you derez an object into your inventory the current state of the script is saved,so there will not be a call to state_entry() during the rez. If you need to provide startup code every timean object is created, you should create a global function and call it from both state_entry() and theon_rez() callbacks.// global initialization function.init(){// Set up a listen callback for whoever owns this object.key owner = llGetOwner();llListen(0, "", owner, "");}default{state_entry(){init();}on_rez(integer start_param){init();}}listen(integer channel, string name, key id, string message){llSay(0, "Hi " + name + "! You own me.");}5.2. state_exit()The state_entry event occurs whenever the state command is used to transition to another state. It is handledbefore the new state’s state_entry event.You will want to provide a state_exit() if you need to clean up any events that you have requested in the currentstate, but do not expect in the next state.default{state_entry(){state TimerState;}18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!