mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-18 06:01:19 +02:00
More parameters for sim.brush
This commit is contained in:
@@ -1919,8 +1919,7 @@ int BrushClosure(lua_State * l)
|
|||||||
int sizeY = lua_tointeger(l, lua_upvalueindex(6));
|
int sizeY = lua_tointeger(l, lua_upvalueindex(6));
|
||||||
int x = lua_tointeger(l, lua_upvalueindex(7));
|
int x = lua_tointeger(l, lua_upvalueindex(7));
|
||||||
int y = lua_tointeger(l, lua_upvalueindex(8));
|
int y = lua_tointeger(l, lua_upvalueindex(8));
|
||||||
float strength = lua_tonumber(l, lua_upvalueindex(9));
|
unsigned char *bitmap = (unsigned char *)lua_touserdata(l, lua_upvalueindex(9));
|
||||||
unsigned char *bitmap = (unsigned char *)lua_touserdata(l, lua_upvalueindex(10));
|
|
||||||
|
|
||||||
|
|
||||||
int yield_x, yield_y;
|
int yield_x, yield_y;
|
||||||
@@ -1953,8 +1952,7 @@ int BrushClosure(lua_State * l)
|
|||||||
|
|
||||||
lua_pushnumber(l, yield_x);
|
lua_pushnumber(l, yield_x);
|
||||||
lua_pushnumber(l, yield_y);
|
lua_pushnumber(l, yield_y);
|
||||||
lua_pushnumber(l, strength);
|
return 2;
|
||||||
return 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaScriptInterface::simulation_brush(lua_State * l)
|
int LuaScriptInterface::simulation_brush(lua_State * l)
|
||||||
@@ -1962,19 +1960,34 @@ int LuaScriptInterface::simulation_brush(lua_State * l)
|
|||||||
// see Simulation::ToolBrush
|
// see Simulation::ToolBrush
|
||||||
int positionX = luaL_checkint(l, 1);
|
int positionX = luaL_checkint(l, 1);
|
||||||
int positionY = luaL_checkint(l, 2);
|
int positionY = luaL_checkint(l, 2);
|
||||||
Brush * cBrush = luacon_model->GetBrush();
|
int brushradiusX = luaL_checkint(l, 3);
|
||||||
int radiusX = cBrush->GetRadius().X, radiusY = cBrush->GetRadius().Y, sizeX = cBrush->GetSize().X, sizeY = cBrush->GetSize().Y;
|
int brushradiusY = luaL_checkint(l, 4);
|
||||||
|
int brushID = luaL_checkint(l, 5);
|
||||||
|
|
||||||
|
vector<Brush *> brushList = luacon_model->GetBrushList();
|
||||||
|
if (brushID < 0 || brushID >= (int)brushList.size())
|
||||||
|
return luaL_error(l, "Invalid brush id '%d'", brushID);
|
||||||
|
|
||||||
|
ui::Point tempRadius = brushList[brushID]->GetRadius();
|
||||||
|
brushList[brushID]->SetRadius(ui::Point(brushradiusX, brushradiusY));
|
||||||
lua_pushnumber(l, positionX);
|
lua_pushnumber(l, positionX);
|
||||||
lua_pushnumber(l, positionY);
|
lua_pushnumber(l, positionY);
|
||||||
|
int radiusX = brushList[brushID]->GetRadius().X;
|
||||||
|
int radiusY = brushList[brushID]->GetRadius().Y;
|
||||||
|
int sizeX = brushList[brushID]->GetSize().X;
|
||||||
|
int sizeY = brushList[brushID]->GetSize().Y;
|
||||||
lua_pushnumber(l, radiusX);
|
lua_pushnumber(l, radiusX);
|
||||||
lua_pushnumber(l, radiusY);
|
lua_pushnumber(l, radiusY);
|
||||||
lua_pushnumber(l, sizeX);
|
lua_pushnumber(l, sizeX);
|
||||||
lua_pushnumber(l, sizeY);
|
lua_pushnumber(l, sizeY);
|
||||||
lua_pushnumber(l, 0);
|
lua_pushnumber(l, 0);
|
||||||
lua_pushnumber(l, 0);
|
lua_pushnumber(l, 0);
|
||||||
lua_pushnumber(l, luacon_model->GetToolStrength());
|
int bitmapSize = sizeX * sizeY;
|
||||||
lua_pushlightuserdata(l, cBrush->GetBitmap());
|
void *bitmapCopy = lua_newuserdata(l, bitmapSize);
|
||||||
lua_pushcclosure(l, BrushClosure, 10);
|
memcpy(bitmapCopy, brushList[brushID]->GetBitmap(), bitmapSize);
|
||||||
|
brushList[brushID]->SetRadius(tempRadius);
|
||||||
|
|
||||||
|
lua_pushcclosure(l, BrushClosure, 9);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user