[Solved]Hero state question

Started by Zefk, August 09, 2018, 11:47:50 PM

Previous topic - Next topic
August 09, 2018, 11:47:50 PM Last Edit: August 10, 2018, 12:33:25 AM by Zefk
I was wondering if there was a way to set the hero's state? All I noticed in the documentation was hero:get_state().

Sometimes the hero gets stuck on a certain state in my scripts and something like the following would be useful.

Code ( lua) Select
hero:set_state("free")

There is no hero:set_state() function because depending on the state you want, there are different parameters needed. Like in the treasure state, you need to specify which treasure you want. For this reason, there are separate functions instead. The one you want is hero:unfreeze(). It unblocks the hero, that is, it restores control to the player.

Ah, got it and that did fix my problem. It was quite odd because the hero would get stuck on the bow state if I pressed "b" and "down" very quickly on a ladder. Not sure if that is a bug. It could just be me.

Code ( lua) Select
         
          --State is a variable in hero:set_animation()
          --hero:set_animation(state)
          if key == "b" then
            hero:start_bow()
          elseif key == "down" and state == "walking" or state == "ladder" then
            hero:unfreeze()
          end