Registriert seit: 18. Sep 2024
2 Beiträge
|
AW: Array von Delphi nach Lua
1. Okt 2024, 16:52
Wenn jmd braucht:
Delphi-Quellcode:
....
Dict.Add('One', '1one');
Dict.Add('Two', '2two');
Dict.Add('Three', '3three');
Lua. DoStream(Stream);
PushDictionaryToLua(Lua.LuaState, Dict); // Push the dictionary to Lua
lua_setglobal(Lua.LuaState, 'myDict');
Delphi-Quellcode:
procedure PushDictionaryToLua(L: lua_State; const Dict: TDictionary<string, string>);
var
Pair: TPair<string, string>;
tmpx, tmpy: AnsiString;
begin
lua_newtable(L); // Create a new table on the stack;
for Pair in Dict do
begin
tmpx := Pair.Key;
tmpy := Pair.Value;
lua_pushlstring(L, PAnsiChar(tmpx), Length(tmpx));
lua_pushlstring(L, PAnsiChar(tmpy), Length(tmpy));
lua_settable(L, -3); // Set the table at the given index
end;
end;
|
|
Zitat
|