Skip to content
Permalink
Browse files

allow using element names as argument 2 to tpt.set_property again

  • Loading branch information...
jacob1 committed Feb 23, 2019
1 parent 768202c commit 1536736b3303db2a84b051fa706340b65ff96416
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/lua/LegacyLuaAPI.cpp
@@ -687,7 +687,7 @@ int luatpt_set_property(lua_State* l)
return luaL_error(l, "Unrecognised element '%s'", name);
}
}
if (lua_isnumber(l, 2) || format == CommandInterface::FormatElement)
if (lua_isnumber(l, 2))
{
if (format == CommandInterface::FormatFloat)
f = luaL_optnumber(l, 2, 0);
@@ -697,12 +697,15 @@ int luatpt_set_property(lua_State* l)
if (!strcmp(prop, "type") && (t<0 || t>=PT_NUM || !luacon_sim->elements[t].Enabled))
return luaL_error(l, "Unrecognised element number '%d'", t);
}
else
else if (lua_isstring(l, 2))
{
name = luaL_checklstring(l, 2, NULL);
if ((t = luacon_sim->GetParticleType(ByteString(name)))==-1)
return luaL_error(l, "Unrecognised element '%s'", name);
}
else
luaL_error(l, "Expected number or element name as argument 2");

if (!lua_isnumber(l, 3) || acount >= 6)
{
// Got a region

0 comments on commit 1536736

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.