MCPcopy Create free account
hub / github.com/The-Powder-Toy/The-Powder-Toy / LuaSetParticleProperty

Function LuaSetParticleProperty

src/lua/LuaScriptInterface.cpp:327–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327void LuaSetParticleProperty(lua_State *L, int particleID, StructProperty property, intptr_t propertyAddress, int stackPos)
328{
329 auto *lsi = GetLSI();
330 auto *sim = lsi->sim;
331 if (property.Name == "type")
332 {
333 lsi->AssertMonopartAccessEvent(-1);
334 sim->part_change_type(particleID, int(sim->parts[particleID].x+0.5f), int(sim->parts[particleID].y+0.5f), luaL_checkinteger(L, 3));
335 }
336 else if (property.Name == "x" || property.Name == "y")
337 {
338 lsi->AssertMonopartAccessEvent(-1);
339 float val = luaL_checknumber(L, 3);
340 float x = sim->parts[particleID].x;
341 float y = sim->parts[particleID].y;
342 float nx = property.Name == "x" ? val : x;
343 float ny = property.Name == "y" ? val : y;
344 sim->move(particleID, (int)(x + 0.5f), (int)(y + 0.5f), nx, ny);
345 }
346 else
347 {
348 lsi->AssertMonopartAccessEvent(particleID);
349 LuaSetProperty(L, property, propertyAddress, 3);
350 }
351}
352
353static int pushGameControllerEvent(lua_State *L, const GameControllerEvent &event)
354{

Callers 1

partPropertyFunction · 0.85

Calls 5

GetLSIFunction · 0.85
LuaSetPropertyFunction · 0.85
part_change_typeMethod · 0.80
moveMethod · 0.80

Tested by

no test coverage detected