# How to make a state machine?

**URL:** <https://forum.defold.com/t/how-to-make-a-state-machine/71324>\
**Category:** Questions\
**Created:** [July 22, 2022, 4:43pm UTC](https://forum.defold.com/t/how-to-make-a-state-machine/71324 "2022-07-22T16:43:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_G\_S](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/miguel_g_s/32/27219_2.png) [@Miguel\_G\_S](https://forum.defold.com/u/Miguel_G_S)\
**Post date:** [July 22, 2022, 4:43pm UTC](https://forum.defold.com/t/how-to-make-a-state-machine/71324/1 "2022-07-22T16:43:59Z")

</div>

hello how do I make a state machine, is there a tutorial on the defoldia website or link that shows how to do it?

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [July 22, 2022, 5:05pm UTC](https://forum.defold.com/t/how-to-make-a-state-machine/71324/2 "2022-07-22T17:05:47Z")

</div>

A few of Lua FSM(mostly they are the same):  
[https://github.com/kyleconroy/lua-state-machine](https://github.com/kyleconroy/lua-state-machine)  
[https://github.com/unindented/lua-fsm](https://github.com/unindented/lua-fsm)  
[https://github.com/recih/lua-fsm](https://github.com/recih/lua-fsm)

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [July 22, 2022, 10:28pm UTC](https://forum.defold.com/t/how-to-make-a-state-machine/71324/3 "2022-07-22T22:28:31Z")

</div>

I personally use the first one linked above 😉 There are also other approaches, some might be simpler for the first time 😉 Basically - if you search for Defold or more general - Lua FSM, there will be a ton of solutions 🙂

There is a video tutorial with a very simple state machine that might be most helpful to you:

[![](https://img.youtube.com/vi/aVFMDiaQ_Qc/maxresdefault.jpg "Simple State Machine in Defold") ](https://www.youtube.com/watch?v=aVFMDiaQ_Qc)

There is also this project by Maksim, working, but not maintained since some time: [GitHub - Insality/defold-adam: The FSM plugin for Defold to describe states like Playmaker in Unity with predefined actions · GitHub](https://github.com/Insality/defold-adam)

And this template: [GitHub - britzl/lowrezadventure: Game for LOWREZJAM 2018 using the Defold game engine · GitHub](https://github.com/britzl/lowrezadventure)  
using stately.lua - also a pretty simple state machine 😉

If you don’t mind, I would like to ask you to let us know which one suits you the best and generally what you would like to have 😉 I am actually interested in developing something more user friendly regarding FSM and also with some visual nodes to represent the connections between states, which might be very helpful to visualizer the FSM 😉
