I am trying to embed a lua-based script in my game engine. I would like the scripts to have both blocking and non-blocking commands, for example:
character.walkTo(24, 359); // Blocks until character arrives
c = 35; // Non blocking, execution goes on to the next statement
Since "walkTo" must be "active" for more than one execution frame, I would like to be able to run 1 time instruction from the Java host instead of the whole function. This is because it would be unnecessary to have real multithreading, which is not needed.
If I could only execute 1 statement and keep the execution state “paused” until the next statement was executed, I could implement lock commands of type “walkTo”, checking if the command completed in the host, and if so, go to the next statement, otherwise wait until the next iteration of the frame.
Is there a way to execute 1 time statement from a Java host using LuaJ (or with any other Lua api), or am I forced to develop my own script engine using lex and yacc?
Any good idea is welcome, thanks!
source
share