summaryrefslogtreecommitdiff
path: root/src/cat/LuaScriptInterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cat/LuaScriptInterface.cpp')
-rw-r--r--src/cat/LuaScriptInterface.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index d981fe7..ef0c1f6 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -435,6 +435,7 @@ void LuaScriptInterface::initSimulationAPI()
{"partCreate", simulation_partCreate},
{"partProperty", simulation_partProperty},
{"partPosition", simulation_partPosition},
+ {"partID", simulation_partID},
{"partKill", simulation_partKill},
{"pressure", simulation_pressure},
{"ambientHeat", simulation_ambientHeat},
@@ -558,6 +559,24 @@ int LuaScriptInterface::simulation_partCreate(lua_State * l)
return 1;
}
+int LuaScriptInterface::simulation_partID(lua_State * l)
+{
+ int x = lua_tointeger(l, 1);
+ int y = lua_tointeger(l, 2);
+
+ if(x < 0 || x >= XRES || y < 0 || y >= YRES)
+ {
+ lua_pushnil(l);
+ return 1;
+ }
+
+ int amalgam = luacon_sim->pmap[y][x];
+ if(!amalgam)
+ amalgam = luacon_sim->photons[y][x];
+ lua_pushinteger(l, amalgam >> 8);
+ return 1;
+}
+
int LuaScriptInterface::simulation_partPosition(lua_State * l)
{
int particleID = lua_tointeger(l, 1);