1

I developing a game engine, and want the game to process a lua file.

Currently I'm using a custom scripting language I wrote to store each command in a list the game can can execute. My scripting language is very primitive at this point, which is why I want to switch to Lua, but I'm not sure how to proceed.

Here is an example of what I'm trying to do:

engine.message("Text")     // Pause until player clicks a button
engine.message("Text2")    // Pause until player clicks a button
chosenValue = engine.choose("Option1|Option2")  // Wait for player to choose, then assign value
if(chosenValue="Option1") then
  engine.message("One")    // Pause until player clicks a button
else
  engine.message("Two")    // Pause until player clicks a button
end
clearlight
  • 12,255
  • 11
  • 57
  • 75
  • Might be a duplicate of http://stackoverflow.com/questions/27588569/is-it-possible-to-execute-a-single-lua-statement-from-a-host-program – clearlight Jan 02 '17 at 20:37

1 Answers1

0

I solved it by running Lua on another thread, and using a Semaphore with 1 permit that is taken when the script starts. When I want to pause, I request a permit from the Lua thread which pauses the whole thing, and when the user clicked a button I release a permit