mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 11:19:51 +02:00
allow creating WIND lines from lua
This commit is contained in:
@@ -506,6 +506,7 @@ void LuaScriptInterface::initSimulationAPI()
|
|||||||
lua_pushinteger(l, TOOL_AIR); lua_setfield(l, simulationAPI, "TOOL_AIR");
|
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_PGRV); lua_setfield(l, simulationAPI, "TOOL_PGRV");
|
||||||
lua_pushinteger(l, TOOL_NGRV); lua_setfield(l, simulationAPI, "TOOL_NGRV");
|
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_DRAW); lua_setfield(l, simulationAPI, "DECO_DRAW");
|
||||||
lua_pushinteger(l, DECO_CLEAR); lua_setfield(l, simulationAPI, "DECO_CLEAR");
|
lua_pushinteger(l, DECO_CLEAR); lua_setfield(l, simulationAPI, "DECO_CLEAR");
|
||||||
lua_pushinteger(l, DECO_ADD); lua_setfield(l, simulationAPI, "DECO_ADD");
|
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 tool = luaL_optint(l,5,0);
|
||||||
int brush = luaL_optint(l,6,CIRCLE_BRUSH);
|
int brush = luaL_optint(l,6,CIRCLE_BRUSH);
|
||||||
float strength = luaL_optnumber(l,7,1.0f);
|
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);
|
return luaL_error(l, "Invalid tool id '%d'", tool);
|
||||||
|
|
||||||
vector<Brush*> brushList = luacon_model->GetBrushList();
|
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 tool = luaL_optint(l,7,0);
|
||||||
int brush = luaL_optint(l,8,CIRCLE_BRUSH);
|
int brush = luaL_optint(l,8,CIRCLE_BRUSH);
|
||||||
float strength = luaL_optnumber(l,9,1.0f);
|
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);
|
return luaL_error(l, "Invalid tool id '%d'", tool);
|
||||||
|
|
||||||
vector<Brush*> brushList = luacon_model->GetBrushList();
|
vector<Brush*> brushList = luacon_model->GetBrushList();
|
||||||
@@ -1141,6 +1147,13 @@ int LuaScriptInterface::simulation_toolLine(lua_State * l)
|
|||||||
ui::Point tempRadius = brushList[brush]->GetRadius();
|
ui::Point tempRadius = brushList[brush]->GetRadius();
|
||||||
brushList[brush]->SetRadius(ui::Point(rx, ry));
|
brushList[brush]->SetRadius(ui::Point(rx, ry));
|
||||||
|
|
||||||
|
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);
|
luacon_sim->ToolLine(x1, y1, x2, y2, tool, brushList[brush], strength);
|
||||||
brushList[brush]->SetRadius(tempRadius);
|
brushList[brush]->SetRadius(tempRadius);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1154,7 +1167,12 @@ int LuaScriptInterface::simulation_toolBox(lua_State * l)
|
|||||||
int y2 = luaL_optint(l,4,-1);
|
int y2 = luaL_optint(l,4,-1);
|
||||||
int tool = luaL_optint(l,5,0);
|
int tool = luaL_optint(l,5,0);
|
||||||
float strength = luaL_optnumber(l,6,1.0f);
|
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);
|
return luaL_error(l, "Invalid tool id '%d'", tool);
|
||||||
|
|
||||||
luacon_sim->ToolBox(x1, y1, x2, y2, tool, strength);
|
luacon_sim->ToolBox(x1, y1, x2, y2, tool, strength);
|
||||||
|
@@ -75,6 +75,7 @@ class LuaScriptInterface: public CommandInterface
|
|||||||
static int simulation_toolBrush(lua_State * l);
|
static int simulation_toolBrush(lua_State * l);
|
||||||
static int simulation_toolLine(lua_State * l);
|
static int simulation_toolLine(lua_State * l);
|
||||||
static int simulation_toolBox(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_decoBrush(lua_State * l);
|
||||||
static int simulation_decoLine(lua_State * l);
|
static int simulation_decoLine(lua_State * l);
|
||||||
static int simulation_decoBox(lua_State * l);
|
static int simulation_decoBox(lua_State * l);
|
||||||
|
@@ -444,7 +444,9 @@ std::vector<std::string> Client::DirectorySearch(std::string directory, std::str
|
|||||||
findFileHandle = _findfirst(fileMatch.c_str(), ¤tFile);
|
findFileHandle = _findfirst(fileMatch.c_str(), ¤tFile);
|
||||||
if (findFileHandle == -1L)
|
if (findFileHandle == -1L)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
printf("Unable to open directory: %s\n", directory.c_str());
|
printf("Unable to open directory: %s\n", directory.c_str());
|
||||||
|
#endif
|
||||||
return std::vector<std::string>();
|
return std::vector<std::string>();
|
||||||
}
|
}
|
||||||
do
|
do
|
||||||
@@ -461,7 +463,9 @@ std::vector<std::string> Client::DirectorySearch(std::string directory, std::str
|
|||||||
DIR *directoryHandle = opendir(directory.c_str());
|
DIR *directoryHandle = opendir(directory.c_str());
|
||||||
if(!directoryHandle)
|
if(!directoryHandle)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
printf("Unable to open directory: %s\n", directory.c_str());
|
printf("Unable to open directory: %s\n", directory.c_str());
|
||||||
|
#endif
|
||||||
return std::vector<std::string>();
|
return std::vector<std::string>();
|
||||||
}
|
}
|
||||||
while(directoryEntry = readdir(directoryHandle))
|
while(directoryEntry = readdir(directoryHandle))
|
||||||
|
@@ -47,7 +47,7 @@ void Tool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Po
|
|||||||
void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
|
void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
|
||||||
sim->ToolBox(position1.X, position1.Y, position2.X, position2.Y, toolID, strength);
|
sim->ToolBox(position1.X, position1.Y, position2.X, position2.Y, toolID, strength);
|
||||||
}
|
}
|
||||||
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {};
|
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {}
|
||||||
|
|
||||||
|
|
||||||
ElementTool::ElementTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
ElementTool::ElementTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
||||||
|
@@ -86,7 +86,7 @@ public:
|
|||||||
}
|
}
|
||||||
virtual ~PropertyTool() {}
|
virtual ~PropertyTool() {}
|
||||||
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) {};
|
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) {}
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false) { }
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false) { }
|
||||||
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { }
|
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { }
|
||||||
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { }
|
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
|
@@ -52,17 +52,6 @@ public:
|
|||||||
|
|
||||||
int currentTick;
|
int currentTick;
|
||||||
|
|
||||||
playerst player;
|
|
||||||
playerst player2;
|
|
||||||
playerst fighters[256]; //255 is the maximum number of fighters
|
|
||||||
unsigned char fighcount; //Contains the number of fighters
|
|
||||||
int lighting_recreate;
|
|
||||||
bool gravWallChanged;
|
|
||||||
Particle portalp[CHANNELS][8][80];
|
|
||||||
Particle emptyparticle;
|
|
||||||
int portal_rx[8];
|
|
||||||
int portal_ry[8];
|
|
||||||
int wireless[CHANNELS][2];
|
|
||||||
char can_move[PT_NUM][PT_NUM];
|
char can_move[PT_NUM][PT_NUM];
|
||||||
int parts_lastActiveIndex;// = NPART-1;
|
int parts_lastActiveIndex;// = NPART-1;
|
||||||
int pfree;
|
int pfree;
|
||||||
@@ -72,6 +61,23 @@ public:
|
|||||||
int ISWIRE;
|
int ISWIRE;
|
||||||
int force_stacking_check;
|
int force_stacking_check;
|
||||||
int emp_decor;
|
int emp_decor;
|
||||||
|
//Stickman
|
||||||
|
playerst player;
|
||||||
|
playerst player2;
|
||||||
|
playerst fighters[256]; //255 is the maximum number of fighters
|
||||||
|
unsigned char fighcount; //Contains the number of fighters
|
||||||
|
int lighting_recreate;
|
||||||
|
bool gravWallChanged;
|
||||||
|
//Portals and Wifi
|
||||||
|
Particle portalp[CHANNELS][8][80];
|
||||||
|
Particle emptyparticle;
|
||||||
|
int portal_rx[8];
|
||||||
|
int portal_ry[8];
|
||||||
|
int wireless[CHANNELS][2];
|
||||||
|
//PROP tool property to draw (TODO)
|
||||||
|
//void *prop_value;
|
||||||
|
//StructProperty::PropertyType proptype;
|
||||||
|
//size_t prop_offset;
|
||||||
//Gol sim
|
//Gol sim
|
||||||
int CGOL;
|
int CGOL;
|
||||||
int GSPEED;
|
int GSPEED;
|
||||||
@@ -97,10 +103,9 @@ public:
|
|||||||
int pmap[YRES][XRES];
|
int pmap[YRES][XRES];
|
||||||
int photons[YRES][XRES];
|
int photons[YRES][XRES];
|
||||||
int pmap_count[YRES][XRES];
|
int pmap_count[YRES][XRES];
|
||||||
//
|
//Simulation Settings
|
||||||
int edgeMode;
|
int edgeMode;
|
||||||
int gravityMode;
|
int gravityMode;
|
||||||
//int airMode;
|
|
||||||
int legacy_enable;
|
int legacy_enable;
|
||||||
int aheat_enable;
|
int aheat_enable;
|
||||||
int VINE_MODE;
|
int VINE_MODE;
|
||||||
|
Reference in New Issue
Block a user