diff options
| author | jacob1 <jfu614@gmail.com> | 2013-01-17 04:48:09 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-01-17 04:48:09 (GMT) |
| commit | 17cd0e74f26b28101edf1ded343e83820d3f4357 (patch) | |
| tree | b3b67b717bf946af99f851e957161fd105f3c56e /src/cat/LuaScriptInterface.cpp | |
| parent | f9f79e4f530c38dd93b32505d630797a7ec2002e (diff) | |
| download | powder-17cd0e74f26b28101edf1ded343e83820d3f4357.zip powder-17cd0e74f26b28101edf1ded343e83820d3f4357.tar.gz | |
add gravmap setting. Getting doesn't work right now, and maybe i should check if gravx/y can be modified too
Diffstat (limited to 'src/cat/LuaScriptInterface.cpp')
| -rw-r--r-- | src/cat/LuaScriptInterface.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 4528b2b..88fe934 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -410,6 +410,7 @@ void LuaScriptInterface::initSimulationAPI() {"ambientHeat", simulation_ambientHeat}, {"velocityX", simulation_velocityX}, {"velocityY", simulation_velocityY}, + {"gravMap", simulation_gravMap}, {NULL, NULL} }; luaL_register(l, "simulation", simulationAPIMethods); @@ -452,7 +453,8 @@ void LuaScriptInterface::set_map(int x, int y, int width, int height, float valu luacon_sim->vx[ny][nx] = value; else if (map == 4) luacon_sim->vy[ny][nx] = value; - + else if (map == 5) + luacon_sim->gravmap[ny*XRES/CELL+nx] = value; //gravx/y don't seem to work, but this does. opposite of tpt } } @@ -671,6 +673,39 @@ int LuaScriptInterface::simulation_velocityY(lua_State* l) return 0; } +int LuaScriptInterface::simulation_gravMap(lua_State* l) +{ + int argCount = lua_gettop(l); + luaL_checktype(l, 1, LUA_TNUMBER); + luaL_checktype(l, 2, LUA_TNUMBER); + int x = lua_tointeger(l, 1); + int y = lua_tointeger(l, 2); + if (x*CELL<0 || y*CELL<0 || x*CELL>=XRES || y*CELL>=YRES) + return luaL_error(l, "coordinates out of range (%d,%d)", x, y); + + /*if (argCount == 2) + { + lua_pushnumber(l, luacon_sim->gravmap[y*XRES/CELL+x]); + return 1; + }*/ + int width = 1, height = 1; + float value; + luaL_checktype(l, 3, LUA_TNUMBER); + if (argCount == 3) + value = (float)lua_tonumber(l, 3); + else + { + luaL_checktype(l, 4, LUA_TNUMBER); + luaL_checktype(l, 5, LUA_TNUMBER); + width = lua_tointeger(l, 3); + height = lua_tointeger(l, 4); + value = (float)lua_tonumber(l, 5); + } + + set_map(x, y, width, height, value, 5); + return 0; +} + //// Begin Renderer API void LuaScriptInterface::initRendererAPI() |
