summaryrefslogtreecommitdiff
path: root/src/cat
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-06-02 01:57:03 (GMT)
committer jacob1 <jfu614@gmail.com>2013-06-02 01:57:03 (GMT)
commit8d7ab7f5e27b9b5ba71b4ef13e4cbb9f7e5a4641 (patch)
treed3bf71c04abc24aa014dbc403421d1821a8c96be /src/cat
parentb16524292e2d8c640e0e4e0801d5cb4e512e4707 (diff)
downloadpowder-8d7ab7f5e27b9b5ba71b4ef13e4cbb9f7e5a4641.zip
powder-8d7ab7f5e27b9b5ba71b4ef13e4cbb9f7e5a4641.tar.gz
allow creating WIND lines from lua
Diffstat (limited to 'src/cat')
-rw-r--r--src/cat/LuaScriptInterface.cpp26
-rw-r--r--src/cat/LuaScriptInterface.h1
2 files changed, 23 insertions, 4 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index 452a14c..cbd8217 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -506,6 +506,7 @@ void LuaScriptInterface::initSimulationAPI()
lua_pushinteger(l, TOOL_AIR); lua_setfield(l, simulationAPI, "TOOL_AIR");
lua_pushinteger(l, TOOL_PGRV); lua_setfield(l, simulationAPI, "TOOL_PGRV");
lua_pushinteger(l, TOOL_NGRV); lua_setfield(l, simulationAPI, "TOOL_NGRV");
+ lua_pushinteger(l, luacon_sim->tools.size()); lua_setfield(l, simulationAPI, "TOOL_WIND");
lua_pushinteger(l, DECO_DRAW); lua_setfield(l, simulationAPI, "DECO_DRAW");
lua_pushinteger(l, DECO_CLEAR); lua_setfield(l, simulationAPI, "DECO_CLEAR");
lua_pushinteger(l, DECO_ADD); lua_setfield(l, simulationAPI, "DECO_ADD");
@@ -1106,7 +1107,12 @@ int LuaScriptInterface::simulation_toolBrush(lua_State * l)
int tool = luaL_optint(l,5,0);
int brush = luaL_optint(l,6,CIRCLE_BRUSH);
float strength = luaL_optnumber(l,7,1.0f);
- if (tool < 0 || tool >= luacon_sim->tools.size())
+ if (tool == luacon_sim->tools.size())
+ {
+ lua_pushinteger(l, 0);
+ return 1;
+ }
+ else if (tool < 0 || tool >= luacon_sim->tools.size())
return luaL_error(l, "Invalid tool id '%d'", tool);
vector<Brush*> brushList = luacon_model->GetBrushList();
@@ -1132,7 +1138,7 @@ int LuaScriptInterface::simulation_toolLine(lua_State * l)
int tool = luaL_optint(l,7,0);
int brush = luaL_optint(l,8,CIRCLE_BRUSH);
float strength = luaL_optnumber(l,9,1.0f);
- if (tool < 0 || tool >= luacon_sim->tools.size())
+ if (tool < 0 || tool >= luacon_sim->tools.size()+1)
return luaL_error(l, "Invalid tool id '%d'", tool);
vector<Brush*> brushList = luacon_model->GetBrushList();
@@ -1141,7 +1147,14 @@ int LuaScriptInterface::simulation_toolLine(lua_State * l)
ui::Point tempRadius = brushList[brush]->GetRadius();
brushList[brush]->SetRadius(ui::Point(rx, ry));
- luacon_sim->ToolLine(x1, y1, x2, y2, tool, brushList[brush], strength);
+ if (tool == luacon_sim->tools.size())
+ {
+ Tool *WindTool = luacon_model->GetToolFromIdentifier("DEFAULT_UI_WIND");
+ WindTool->DrawLine(luacon_sim, brushList[brush], ui::Point(x1, y1), ui::Point(x2, y2));
+ return 1;
+ }
+ else
+ luacon_sim->ToolLine(x1, y1, x2, y2, tool, brushList[brush], strength);
brushList[brush]->SetRadius(tempRadius);
return 0;
}
@@ -1154,7 +1167,12 @@ int LuaScriptInterface::simulation_toolBox(lua_State * l)
int y2 = luaL_optint(l,4,-1);
int tool = luaL_optint(l,5,0);
float strength = luaL_optnumber(l,6,1.0f);
- if (tool < 0 || tool >= luacon_sim->tools.size())
+ if (tool == luacon_sim->tools.size())
+ {
+ lua_pushinteger(l, 0);
+ return 1;
+ }
+ else if (tool < 0 || tool >= luacon_sim->tools.size())
return luaL_error(l, "Invalid tool id '%d'", tool);
luacon_sim->ToolBox(x1, y1, x2, y2, tool, strength);
diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h
index d8ad350..6556d35 100644
--- a/src/cat/LuaScriptInterface.h
+++ b/src/cat/LuaScriptInterface.h
@@ -75,6 +75,7 @@ class LuaScriptInterface: public CommandInterface
static int simulation_toolBrush(lua_State * l);
static int simulation_toolLine(lua_State * l);
static int simulation_toolBox(lua_State * l);
+ static int simulation_floodProp(lua_State * l);
static int simulation_decoBrush(lua_State * l);
static int simulation_decoLine(lua_State * l);
static int simulation_decoBox(lua_State * l);