我正在使用受 Lua 保护的调用,但我收到了一个不受保护的错误:
lua_getfield( m_L, LUA_GLOBALSINDEX, "startIteration" ); // 1
if( lua_isfunction( m_L, -1 ) ){
lua_pushnumber( m_L, n ); // 2
auto ret = lua_pcall( m_L, 1, 0, 0 ); // 0
checkLuaReturn( m_L, ret );
}else{
lua_pop( m_L, 1 ); // 0
}
错误是:
PANIC: unprotected error in call to Lua API (../example/ex01.lua:31: attempt to index global 'raster' (a nil value))
Lua代码是:
function startIteration( num )
io.write( "Start iteration " .. num .. "\n" )
raster.grass.save( "output.png" )
end
我怎样才能解决它,以获得真正受保护的电话?
更新:修复了额外的流行音乐