fix tpt.set_property again
This commit is contained in:
parent
e5941950ba
commit
7603da0242
@ -1118,14 +1118,10 @@ int luatpt_set_property(lua_State* l)
|
|||||||
size_t offset;
|
size_t offset;
|
||||||
acount = lua_gettop(l);
|
acount = lua_gettop(l);
|
||||||
prop = luaL_optstring(l, 1, "");
|
prop = luaL_optstring(l, 1, "");
|
||||||
i = abs(luaL_optint(l, 3, -1)); //x coord or particle index, depending on arguments
|
|
||||||
y = abs(luaL_optint(l, 4, -1));
|
|
||||||
w = abs(luaL_optint(l, 5, -1));
|
|
||||||
h = abs(luaL_optint(l, 6, -1));
|
|
||||||
|
|
||||||
CommandInterface::FormatType format;
|
CommandInterface::FormatType format;
|
||||||
offset = luacon_ci->GetPropertyOffset(prop, format);
|
offset = luacon_ci->GetPropertyOffset(prop, format);
|
||||||
if(offset == -1)
|
if (offset == -1)
|
||||||
return luaL_error(l, "Invalid property '%s'", prop);
|
return luaL_error(l, "Invalid property '%s'", prop);
|
||||||
|
|
||||||
if (acount > 2)
|
if (acount > 2)
|
||||||
@ -1153,16 +1149,23 @@ int luatpt_set_property(lua_State* l)
|
|||||||
if ((t = luacon_ci->GetParticleType(std::string(name)))==-1)
|
if ((t = luacon_ci->GetParticleType(std::string(name)))==-1)
|
||||||
return luaL_error(l, "Unrecognised element '%s'", name);
|
return luaL_error(l, "Unrecognised element '%s'", name);
|
||||||
}
|
}
|
||||||
if (i == -1 || (w != -1 && h != -1))
|
if (!lua_isnumber(l, 3) || acount >= 6)
|
||||||
{
|
{
|
||||||
// Got a region
|
// Got a region
|
||||||
if (i == -1)
|
if (acount < 6)
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
w = XRES;
|
w = XRES;
|
||||||
h = YRES;
|
h = YRES;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = abs(luaL_checkint(l, 3));
|
||||||
|
y = abs(luaL_checkint(l, 4));
|
||||||
|
w = abs(luaL_checkint(l, 5));
|
||||||
|
h = abs(luaL_checkint(l, 6));
|
||||||
|
}
|
||||||
if (i>=XRES || y>=YRES)
|
if (i>=XRES || y>=YRES)
|
||||||
return luaL_error(l, "Coordinates out of range (%d,%d)", i, y);
|
return luaL_error(l, "Coordinates out of range (%d,%d)", i, y);
|
||||||
x = i;
|
x = i;
|
||||||
@ -1189,9 +1192,11 @@ int luatpt_set_property(lua_State* l)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
i = abs(luaL_checkint(l, 3));
|
||||||
// Got coords or particle index
|
// Got coords or particle index
|
||||||
if (i != -1 && y != -1)
|
if (lua_isnumber(l, 4))
|
||||||
{
|
{
|
||||||
|
y = abs(luaL_checkint(l, 4));
|
||||||
if (i>=XRES || y>=YRES)
|
if (i>=XRES || y>=YRES)
|
||||||
return luaL_error(l, "Coordinates out of range (%d,%d)", i, y);
|
return luaL_error(l, "Coordinates out of range (%d,%d)", i, y);
|
||||||
r = luacon_sim->pmap[y][i];
|
r = luacon_sim->pmap[y][i];
|
||||||
|
Loading…
Reference in New Issue
Block a user