[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Rules engine in Lua?
- From: Fabien <fleutot+lua@...>
- Date: Mon, 14 Jan 2008 15:42:15 +0100
There is a state machine extension under development for metalua 0.4. It lets you write things like this:
-{ extension 'machine' }
machine M
state init
when exit do print "Machine M is starting" end
on START -> State1
state State1
when enter do
print "do whatever you want in this Lua block"
print "it will be evaluated every time the machine enters state S1"
end
on SOME_MSG -> State2
state State2
do
print "there's no explicit 'when' before this action block;"
print "It's run when entering and updating the state by default"
end
on SOME_OTHER_MSG, OR_YET_ANOTHER_MSG -> State1
end
M 'START' -- starts the machine, transitions it from state init to State1
(not seriously tested yet, probably doesn't work on metalua 0.3).
http://repo.or.cz/w/metalua.git?a=blob;f=src/lib/extension-compiler/machine.mlua
http://repo.or.cz/w/metalua.git?a=blob;f=src/lib/extension-runtime/machine.lua