Author Topic: Change images states with a function  (Read 644 times)

I searched far and wide but I haven't found a setState command or anything that resembles it. Is there really no way to change image states using a function?

There is no such method or function in the game. The main way of manipulating the state system through script is ammo. You have access to the %player.setImageAmmo(%slot, %ammo) method, which can be used in conjunction with stateTransitionOnAmmo and stateTransitionOnNoAmmo to do more complex things, but there is no easy way. I think if you need more complexity you can do setImageLoaded with some transitions for that too, but for really complex stuff, you need to be clever about how you set things up. You can also use ammo/noammo in conjunction with onTimeout, where the former will take precedence. I believe this also is where stateWaitForTimeout comes into play, in deciding whether to wait for the timeout to do the on[No]Ammo transition or doing it immediately when the value is set. Finally, a word of caution: jes found the hard way a bit ago that you can create a cycle of no/ammo/triggerdown/up transitions, which will work as an infinite loop and crash the game. The thing you have to do is plan out states before setting them up, because given what we have to work with, this can turn into a huge mess fast.