From 5ea1889e819e270d68a99d6d8179f8a42e9e5dfc Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 20 Aug 2012 14:24:19 +0100 Subject: [PATCH] TPT: fix set_property not checking stacked particles when specifying range, add dcolor property setting/getting --- src/cat/LuaScriptInterface.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index bcf20098a..aa534f37d 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1306,22 +1306,24 @@ int luatpt_set_property(lua_State* l) w = XRES-x; if(y+h > YRES) h = YRES-y; - for (nx = x; nxpmap[ny][nx]; - if (!r || (partsel && partsel != luacon_sim->parts[r>>8].type)) + Particle * parts = luacon_sim->parts; + for (i = 0; i < NPART; i++) + { + 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){ - *((float*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = f; - } else { - *((int*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = t; + if(format == CommandInterface::FormatFloat){ + *((float*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = f; + } else { + *((int*)(((unsigned char*)&luacon_sim->parts[i])+offset)) = t; + } } } + } + } else { // Got coords or particle index if(i != -1 && y != -1){ @@ -1535,6 +1537,10 @@ int luatpt_get_property(lua_State* l) lua_pushinteger(l, luacon_sim->parts[i].dcolour); return 1; } + if (strcmp(prop,"dcolor")==0){ + lua_pushinteger(l, luacon_sim->parts[i].dcolour); + return 1; + } if (strcmp(prop,"id")==0){ lua_pushnumber(l, i); return 1;