Add sim.listStamps

This commit is contained in:
Tamás Bálint Misius 2023-12-23 19:26:19 +01:00
parent 62b116cb8f
commit bbe84e3505
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

@ -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);