Lua PANIC: No Calling Environment

BlitzMax Forums/BlitzMax Programming/Lua PANIC: No Calling Environment

Ragz(Posted 2006) [#1]
I recently updated axe.lua, and now the somewhere in the area after "' HERE" I get a lua error of: "PANIC: unprotected error in call to Lua API (no calling environment)"

Local state@ Ptr = luaL_newstate()

lua_pushstring(state,"cursor")
lua_createtable(state,0,3)
	lua_pushstring(state,"x")
	lua_pushnumber(state,0)
	lua_settable(state,-3)
	lua_pushstring(state,"y")
	lua_pushnumber(state,0)
	lua_settable(state,-3)
	lua_pushstring(state,"button")
	lua_pushnumber(state,0)
	lua_settable(state,-3)
lua_settable(state,LUA_GLOBALSINDEX)

' HERE

luaopen_base(state)
luaopen_table(state)
luaopen_io(state)
luaopen_string(state)
luaopen_math(state)
luaopen_debug(state)


Anyone know what I'm doing wrong now?


skidracer(Posted 2006) [#2]
Hmmm, luaopen_io seems to be unsupported in the current version of the module.


skidracer(Posted 2006) [#3]
How about this code:

Strict

Import axe.lua

Local state:Byte Ptr = luaL_newstate()

luaL_openlibs(state) 'replaces all lua_open calls for correct initialization of lua...

lua_pushstring(state,"cursor")
lua_createtable(state,0,3)
lua_pushstring(state,"x")
lua_pushnumber(state,0)
lua_settable(state,-3)
lua_pushstring(state,"y")
lua_pushnumber(state,0)
lua_settable(state,-3)
lua_pushstring(state,"button")
lua_pushnumber(state,0)
lua_settable(state,-3)
lua_settable(state,LUA_GLOBALSINDEX)