From bbe84e3505e43468409b73fc25676f40b18027e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Sat, 23 Dec 2023 19:26:19 +0100 Subject: [PATCH] Add sim.listStamps --- src/lua/LuaScriptInterface.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index 986ca704a..0f70d393e 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -1113,6 +1113,8 @@ int simulation_deletesign(lua_State *l) //// Begin Simulation API +static int simulation_listStamps(lua_State *l); + void LuaScriptInterface::initSimulationAPI() { auto &sd = SimulationData::CRef(); @@ -1157,6 +1159,7 @@ void LuaScriptInterface::initSimulationAPI() {"saveStamp", simulation_saveStamp}, {"loadStamp", simulation_loadStamp}, {"deleteStamp", simulation_deleteStamp}, + {"listStamps", simulation_listStamps}, {"loadSave", simulation_loadSave}, {"reloadSave", simulation_reloadSave}, {"getSaveID", simulation_getSaveID}, @@ -2266,6 +2269,21 @@ int LuaScriptInterface::simulation_deleteStamp(lua_State * l) return 1; } +static int simulation_listStamps(lua_State *l) +{ + lua_newtable(l); + auto &client = Client::Ref(); + auto &stampIDs = client.GetStamps(); + auto i = 0; + for (auto &stampID : stampIDs) + { + tpt_lua_pushByteString(l, stampID); + i += 1; + lua_rawseti(l, -2, i); + } + return 1; +} + int LuaScriptInterface::simulation_loadSave(lua_State * l) { int saveID = luaL_optint(l,1,0);