usesLua,LuaLib;typeTMyLua=class(TLua)publishedfunctionHelloWorld(LuaState:TLuaState):Integer;end;functionTMyLua.HelloWorld(LuaState:TLuaState):Integer;varArgCount:Integer;I:integer;beginArgCount:=Lua_GetTop(LuaState);writeln('Delphi:HelloWorld');writeln('Arguments:',ArgCount);forI:=1toArgCountdowriteln('Arg1',I,':',Lua_ToInteger(LuaState,I));//ClearstackLua_Pop(LuaState,Lua_GetTop(LuaState));//PushreturnvaluesLua_PushInteger(LuaState,101);Lua_PushInteger(LuaState,102);Result:=2;end;varMyLua:TLua;beginMyLua:=TMyLua.Create;MyLua.DoFile('Helloworld.lua');MyLua.Free;end;helloworld.luaprint("LuaDelphiTest");p1,p2=HelloWorld(1,2,3)print"Results:";print(p1);print(p2);
1