From f3a7d966d28a486e9d8bec4d0156ad634463ccbe Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 13 Jul 2017 20:55:03 -0400 Subject: [PATCH] potential fix in sim.partCreate, also --- src/lua/LuaScriptInterface.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index 6c8d48cd29..90c5e3e591 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -898,7 +898,12 @@ int LuaScriptInterface::simulation_partChangeType(lua_State * l) int LuaScriptInterface::simulation_partCreate(lua_State * l) { int newID = lua_tointeger(l, 1); - if(newID >= NPART || newID < -3) + if (newID >= NPART || newID < -3) + { + lua_pushinteger(l, -1); + return 1; + } + if (newID >= 0 && !luacon_sim->parts[newID].type) { lua_pushinteger(l, -1); return 1;