lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, experts
 
I had trouble to run my LuaScene after I just added another table in Lua library registration. The code below is part of LuaScene program. Is there some explanation why it fails?
 
Please pardon my Pascal.
 
Thanks in advance.
 
Geo 
 
// Lua library registration
function luaopen_scene(L : PLua_State) : Integer;
var
  i : Integer;
begin
  // Store Scene functions in 'scene' table
  luaL_openlib(L, 'scene', @_sceneLib, 0);
 
  // Store Scene constants in 'scene' table
  lua_pushstring(L, 'scene');
  lua_gettable(L, LUA_GLOBALSINDEX);
  i := 0;
  repeat
    lua_pushstring(L, _constants[i].name);
    lua_pushstring(L, _constants[i].value);
    lua_rawset(L, -3);
    Inc(i);
  until _constants[i].name = nil;
 
  // Store key constants in 'keybaord' table
  i := 0;
  repeat
    lua_pushstring(L, _keys[i].name);
    lua_pushnumber(L, _keys[i].value);
    lua_rawset(L, -3);
    Inc(i);
  until _keys[i].name = nil;
  lua_setglobal(L, 'keyboard');
 
  // Store mouse button constants in 'mouse' table
  i := 0;
  repeat
    lua_pushstring(L, _buttons[i].name);
    lua_pushnumber(L, _buttons[i].value);
    lua_rawset(L, -3);
    Inc(i);
  until _buttons[i].name = nil;
  lua_setglobal(L, 'mouse');
 
  lua_settop(L, 0);
  result := 0;
end;