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&#40;76,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;77,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;78,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;79,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;80,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;81,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;82,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;83,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;84,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;85,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;86,68&#41; Error&#58; Incompatible type for arg no. 4&#58; Got "SmallInt", expected "<procedure>"
LuaCRT.pas&#40;233&#41; Fatal&#58; There were 11 errors compiling module, stopping
LuaCRT.pas&#40;5,50&#41; Fatal&#58; 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. :?