Clean Up Your States

When developing using states, don’t forget that the state_exit event can be used to perform cleanup instead of repeating cleanup tasks at each exit point from the state.

You can uses the state_exit to clear timers, shut off listens, reset globals, etc. While much of this cleans itself during the state change, things like timers persist through state changes and since you never know when something could change in the underlying LSL (perhaps listens will eventually survive state changes), it’s better to do proper cleanup yourself.

Leave a Reply