LUA Bug?
BlitzMax Forums/BlitzMax Module Tweaks/LUA Bug?
| ||
using the following BlitzMAX code:
Import axe.luascript
Global scriptEnv:TLuaScriptEngine = New TLuaScriptEngine
scriptEnv.reset()
ScriptEnv.RunScriptFile("test.lua")
ScriptEnv.Shutdown()
and the following lua script 'test.lua': print("LUA Script Start") f=io.output("c:\test.txt") f:write("Hello, World!") f:close() print("LUA Script End") I get the script start message but not the end? If I comment out the three lines in the middle then I get the end message as well? Can anyone point me to where I am going wrong? |
| ||
| futher investigation reveals the line luaopen_io(m_lua_state) is comented out in luascript.bmx? I have tried adding it to the code, below the reset() ie:
Import axe.luascript
Global scriptEnv:TLuaScriptEngine = New TLuaScriptEngine
scriptEnv.reset()
luaopen_io(scriptEnv.m_lua_state)
ScriptEnv.RunScriptFile("test.lua")
ScriptEnv.Shutdown()
now I get an Unhandled Memory Exception error? |
| ||
| Thats strange, the example I added to the LUA script engine doc is no longer working either, will try and work out what has happened. |
| ||
| I tried to do this using straight Lua (because I consider the LuaScript module to be evil) and the IO functions work but it's throwing a hissy-fit on lua_close. Example: foo.lua [/code] -- foo.lua local file = io.open( "foo.lua", "r" ) for line in file:lines( ) do print( line ) end --file:close( ) --file = nil -- end: foo.lua [/code] |