uses
Lua, LuaLib;
type
TMyLua = class(TLua)
published
function HelloWorld(LuaState: TLuaState): Integer;
end;
function TMyLua.HelloWorld(LuaState: TLuaState): Integer;
var
ArgCount: Integer;
I: integer;
begin
ArgCount := Lua_GetTop(LuaState);
writeln('Delphi: Hello World');
writeln('Arguments: ', ArgCount);
for I := 1 to ArgCount do
writeln('Arg1', I, ': ', Lua_ToInteger(LuaState, I));
// Clear stack
Lua_Pop(LuaState, Lua_GetTop(LuaState));
// Push return values
Lua_PushInteger(LuaState, 101);
Lua_PushInteger(LuaState, 102);
Result := 2;
end;
var
MyLua: TLua;
begin
MyLua := TMyLua.Create;
MyLua.DoFile('Helloworld.lua');
MyLua.Free;
end;
helloworld.lua
print("LuaDelphi Test");
p1,p2 = HelloWorld(1,2,3)
print "Results:";
print (p1);
print (p2);
1