Okay, I tried this, and it raises the error that it has insufficient arguments.
[pascal]procedure RegisterCRT(L: PLua_State);
var
idx : Integer;
begin
lua_pushliteral(L, 'crt');
lua_newtable(L);
idx := lua_gettop(L);
LuaRegisterCustom(L, 'KeyPressed', lua_KeyPressed, idx);
LuaRegisterCustom(L, 'ReadKey', lua_ReadKey, idx);
LuaRegisterCustom(L, 'GetXY', lua_GetXY, idx);
LuaRegisterCustom(L, 'TextColor', lua_TextColor, idx);
LuaRegisterCustom(L, 'BackgroundColor', lua_BackgroundColor, idx);
LuaRegisterCustom(L, 'ClrScr', lua_ClrScr, idx);
LuaRegisterCustom(L, 'ClrEol', lua_ClrEol, idx);
LuaRegisterCustom(L, 'DelLine', lua_DelLine, idx);
LuaRegisterCustom(L, 'GotoXY', lua_GotoXY, idx);
LuaRegisterCustom(L, 'InsLine', lua_InsLine, idx);
LuaRegisterCustom(L, 'Window', lua_Window, idx);
// lua_settable(L,idx);
lua_settable(L, LUA_GLOBALSINDEX);
end;[/pascal]
But when I try this, it completely freaks out with the following error messages:[pascal]procedure RegisterCRT(L: PLua_State);
var
idx : Integer;
begin
lua_pushliteral(L, 'crt');
lua_newtable(L);
idx := lua_gettop(L);
LuaRegisterCustom(L, 'KeyPressed', @lua_KeyPressed, idx);
LuaRegisterCustom(L, 'ReadKey', @lua_ReadKey, idx);
LuaRegisterCustom(L, 'GetXY', @lua_GetXY, idx);
LuaRegisterCustom(L, 'TextColor', @lua_TextColor, idx);
LuaRegisterCustom(L, 'BackgroundColor', @lua_BackgroundColor, idx);
LuaRegisterCustom(L, 'ClrScr', @lua_ClrScr, idx);
LuaRegisterCustom(L, 'ClrEol', @lua_ClrEol, idx);
LuaRegisterCustom(L, 'DelLine', @lua_DelLine, idx);
LuaRegisterCustom(L, 'GotoXY', @lua_GotoXY, idx);
LuaRegisterCustom(L, 'InsLine', @lua_InsLine, idx);
LuaRegisterCustom(L, 'Window', @lua_Window, idx);
// lua_settable(L,idx);
lua_settable(L, LUA_GLOBALSINDEX);
end;[/pascal]
Code:
LuaCRT.pas(76,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(77,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(78,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(79,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(80,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(81,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(82,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(83,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(84,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(85,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(86,68) Error: Incompatible type for arg no. 4: Got "SmallInt", expected "<procedure>"
LuaCRT.pas(233) Fatal: There were 11 errors compiling module, stopping
LuaCRT.pas(5,50) Fatal: Compilation aborted
Should I try "function as lua_CFunction" or "lua_CFunction(function)"? This is a bit crazy. I hope this doesn't occur very frequently when messing with Lua initially. :?
Bookmarks