Blitzmax + LUA
BlitzMax Forums/BlitzMax Programming/Blitzmax + LUA
| ||
Hi! I am trying to interact with my program by changing a separate LUA file. This example program will load a lua script from a file named "script.lua" once I press F5: script.lua: function hello() print(Demo.SayHello('Fredward')) end function goodbye() print(Demo.SayHello('Stingray Sam')) end Now, that this even works at all is pretty magical to me :) But if I create a typo/error in script.lua, I can only see the error in the debugger. Is there a way to catch the error and display it to the user (e.g. in a MessageBox/Notify)? Thanks! |
| ||
I "hacked" brl.maxlua to achieve the above:... Type TLuaClass Method GetLuaState:Byte Ptr() Return LuaState() End Method ... End Type In Method lua_pushchunk() I disabled line 'lua_pop L,1to keep the error on the stack Now I can use If instance = Null Local debuginfo:String = lua_tostring(class.GetLuaState(), -1) Notify("Error: " + debuginfo, True) |
| ||
I've not used brl.maxlua but I find Pub.lua and lugi (http://www.blitzbasic.com/Community/posts.php?topic=85902) to be a very good combination. For example using Pub.lua you can get compile errors using: Result = lua_pcall(Lua, Inputs, Outputs, 0) If (Result <> 0) then Print("Lua Runtime Error: ~n" + luaL_checkstring(Lua, - 1) ) EndIf |
| ||
Thanks, I will look into that! |