Lua ScriptEngine - Remember global variables

BlitzMax Forums/BlitzMax Programming/Lua ScriptEngine - Remember global variables

Ratchet(Posted 2005) [#1]
I'm using the Lua script engine module for my project. If I use SetScriptText and run it via RunScript, my variables from the last script are gone. How can I set global variables which are always available?


Scott Shaver(Posted 2005) [#2]
I can think of two ways and there is probably a better way than either of these.

1> Make your main loop be in the script file. So instead of having a while loop or something in your blitz program just call a script that have a loop in it. the script basically never exits. It loops calling your program to do the rendering.

2> Have a set/get of funcitons the script can call to set values in your blitz program. That way they never go away.


Ratchet(Posted 2005) [#3]
1> Then I have to rebuild my hole program and have to wrapp all Blitz functions I use to Lua!

2>That's what I'm doing currently. I don't like that way. I want to use real variables.