Getting LUA error msg
BlitzMax Forums/BlitzMax Beginners Area/Getting LUA error msg
| ||
Anyone know how to get an error message from LUA? I'm not calling any functions from LUA, I'm simply running a LUA script via lua_dofile(LuaState, "test.lua") and nothing really happens if there's a syntax error or something, I'd like to print LUA errors but can't figure out how to actually GET the error messages from LUA. |
| ||
If luaL_dofile(luastate,"test.lua") Print "[ERROR] "+lua_tostring(luastate,-1) EndIf |
| ||
Well... *cough* that was easy, heh. Thanks for the straight forward answer mate. :] |
| ||
It returns true when an error occurred? Are you sure? |
| ||
It returns the whole error message, it works perfectly. |
| ||
It returns true when an error occurred? Are you sure? Yes. If there were no errors, it returns 0. |
| ||
That doesn't make sense at all... |
| ||
Yes it does. If an error occurred, luaL_dofile() returns True. If there were no errors, luaL_dofile() returns False. http://pgl.yoyo.org/luai/i/luaL_dofile |
| ||
It makes more sense to say If Not luaL_dofile(luaState, "test.lua") 'Error occurred End If Imo the current way is reversed logic... |
| ||
Does any of you know how to store a LUA function in my field? I've tried to use lua_tocfunction() but can't get it to really work... What I basically want to do is have a button in BlitzMax as the type Gadget with a field called Func() and then in LUA do something like function Clicked() print("Hey!") end gadgetfunction(Clicked) Which would set my Func() field into the LUA function Clicked(), then when I click the button just call Func() I guess what I'm asking is... how do I pass a function as a parameter in LUA? |