A closure-based finite state machine (FSM) implementation

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
allsey87
Prole
Posts: 5
Joined: Mon Jul 29, 2019 9:37 am

A closure-based finite state machine (FSM) implementation

Post by allsey87 »

Hi everyone,

I have created a minimalist synchronous finite state machine using Lua closures that some of you may be interested in. The repository is located on Github: https://github.com/allsey87/luafsm

Unlike other implementations, this has been written from scratch in Lua (it is not a port from another library) and is designed for expressing complex behavior in a modular way (e.g. complex hierarchies of substates can be generated using factories). Please use the issue tracker on Github if you find any bugs or would like me to add any features.

Have fun!
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: A closure-based finite state machine (FSM) implementation

Post by pgimeno »

Looks interesting. What's the license for using this library?
User avatar
YoungNeer
Party member
Posts: 118
Joined: Wed May 15, 2019 7:49 am

Re: A closure-based finite state machine (FSM) implementation

Post by YoungNeer »

I always thought closures are useless in context of making games - but looks like you proved me wrong. I would like to know in which way were closures helpful to you. (Cause I always thought closures are not worth-learning if you only want to make games with lua)
My Github- your contribution is highly appreciated
allsey87
Prole
Posts: 5
Joined: Mon Jul 29, 2019 9:37 am

Re: A closure-based finite state machine (FSM) implementation

Post by allsey87 »

pgimeno wrote: Mon Jul 29, 2019 1:29 pm Looks interesting. What's the license for using this library?
I have released it under an MIT license. The license is now included in the repository.
YoungNeer wrote: Mon Jul 29, 2019 1:36 pm I always thought closures are useless in context of making games - but looks like you proved me wrong. I would like to know in which way were closures helpful to you. (Cause I always thought closures are not worth-learning if you only want to make games with lua)
So closures in the case of this library are the states themselves which are runnable. You execute a state by running it. Since I wanted to avoid writing a function for every superstate (each of which would contain different child states), I just have a generic superstate factory function which generates closures containing the child states, exit, and entry functions as upvalues. I know that sounds a bit cryptic, but I think the only way to really get your head around it is to play with them for a bit.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: A closure-based finite state machine (FSM) implementation

Post by pgimeno »

allsey87 wrote: Tue Jul 30, 2019 2:09 pm I have released it under an MIT license. The license is now included in the repository.
Thanks a lot!
Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests