TPT: fix set_property not checking stacked particles when specifying range, add dcolor property setting/getting
This commit is contained in:
parent
fb02d57aca
commit
5ea1889e81
@ -1306,22 +1306,24 @@ int luatpt_set_property(lua_State* l)
|
|||||||
w = XRES-x;
|
w = XRES-x;
|
||||||
if(y+h > YRES)
|
if(y+h > YRES)
|
||||||
h = YRES-y;
|
h = YRES-y;
|
||||||
for (nx = x; nx<x+w; nx++)
|
Particle * parts = luacon_sim->parts;
|
||||||
for (ny = y; ny<y+h; ny++){
|
for (i = 0; i < NPART; i++)
|
||||||
r = luacon_sim->pmap[ny][nx];
|
{
|
||||||
if (!r || (partsel && partsel != luacon_sim->parts[r>>8].type))
|
if (parts[i].type)
|
||||||
|
{
|
||||||
|
nx = (int)(parts[i].x + .5f);
|
||||||
|
ny = (int)(parts[i].y + .5f);
|
||||||
|
if (nx >= x && nx < x+w && ny >= y && ny < y+h && (!partsel || partsel == parts[i].type))
|
||||||
{
|
{
|
||||||
r = luacon_sim->photons[ny][nx];
|
|
||||||
if (!r || (partsel && partsel != luacon_sim->parts[r>>8].type))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
i = r>>8;
|
|
||||||
if(format == CommandInterface::FormatFloat){
|
if(format == CommandInterface::FormatFloat){
|
||||||
*((float*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = f;
|
*((float*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = f;
|
||||||
} else {
|
} else {
|
||||||
*((int*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = t;
|
*((int*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Got coords or particle index
|
// Got coords or particle index
|
||||||
if(i != -1 && y != -1){
|
if(i != -1 && y != -1){
|
||||||
@ -1535,6 +1537,10 @@ int luatpt_get_property(lua_State* l)
|
|||||||
lua_pushinteger(l, luacon_sim->parts[i].dcolour);
|
lua_pushinteger(l, luacon_sim->parts[i].dcolour);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (strcmp(prop,"dcolor")==0){
|
||||||
|
lua_pushinteger(l, luacon_sim->parts[i].dcolour);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (strcmp(prop,"id")==0){
|
if (strcmp(prop,"id")==0){
|
||||||
lua_pushnumber(l, i);
|
lua_pushnumber(l, i);
|
||||||
return 1;
|
return 1;
|
||||||
|
Reference in New Issue
Block a user