From ae253ebc754d6d377c25e278442cfc4bf42af5c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Wed, 6 Jul 2022 11:34:21 +0200 Subject: [PATCH] Add real v parameter to sim.partCreate Currently it detects presence of v incorrectly (via if (ID(type))) and thus rewrites v = 0 to v = -1, even if 0 is actually what you want. Especially problematic if you're trying to spawn GOL (so LIFE(ctype=0)). --- src/lua/LuaScriptInterface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index aa80631a2..6f36ba16a 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -1031,7 +1031,11 @@ int LuaScriptInterface::simulation_partCreate(lua_State * l) } int type = lua_tointeger(l, 4); int v = -1; - if (ID(type)) + if (lua_gettop(l) >= 5) + { + v = lua_tointeger(l, 5); + } + else if (ID(type)) { v = ID(type); type = TYP(type);