Coder Social home page Coder Social logo

lua-state-machine's Issues

Library not loading into Defold game engine

Hi, have the developers tried to add this library to a Defold project as a dependency? I'm able to attach other github releases on Defold, however for some reason this library doesn't load in.

State does not change back to initial with 3-way omnidirectional non-wildcard state machine

local m = statemachine.create{
    initial = "idle",
    events = {
        {name = "one", from = {"idle", "two"}, to = "one"},
        {name = "two", from = {"one", "idle"}, to = "two"},
        {name = "idle", from = {"one, two"}, to = "idle"},
    }
}
print("idle", m.current)
m:one()
print("one", m.current)
m:idle()
print("idle", m.current)

produces output:

idle    idle
one     one
idle    one

What's going on here? I've tried changing the event names to be different to the states they transition to, but I'm still having this problem.

Publish to LuaRocks?

It'd be awesome to have this package on LuaRocks, so that I can depend on it without having to copy files manually...

Tail calls gives "stack overflow"

According to http://www.lua.org/pil/6.3.html lua supports tail calls, and the following example really gives infinite loop

function room1()
    print("Room1")
    return room2()
end

function room2()
    print("Room2")
    return room3()
end

function room3()
    print("Room3")
    return room1()
end

room1()

Yet, direct implementation of this code using lua-state-machine yields stack overflow

local machine = require 'statemachine'

local fsm = machine.create({
    initial = 'room1',

    events = {
        { name = 'go', from = 'room1', to = 'room2' },
        { name = 'go', from = 'room2', to = 'room3' },
        { name = 'go', from = 'room3', to = 'room1' },
    },
    callbacks = {
        onroom1 = function(self, event, from, to) print("Room1"); return self:go() end,
        onroom2 = function(self, event, from, to) print("Room2"); return self:go() end,
        onroom3 = function(self, event, from, to) print("Room3"); return self:go() end,
    }
})

fsm:go()

Well, may be I am not using it properly...

Clean example

Hi!

Can you make an example of the work for the state-machine state hero

  1. Stand
  2. Move (left, right)
  3. Jump on the spot
  4. Move to the left and Jump
  5. Move to the right and Jump
  6. Death

I would have really helped this example to understand the state-machine.
Thank!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.