adding a lua function to allow lua to switch states. (caution curently doesn't work, some lua error)