when I try setting the life of an energy particle it just dies rather then working, my goal is to make it work like neutrons where you spawn it and it slowly loses life and then dies.
my current code:
I tried adding that and it didn't work
You can handle it like this:
local pion = elements.allocate("PARTICLES", "PION")
elements.element(pion, elements.element(elements.DEFAULT_PT_NEUT))
elements.property(pion, "Name", "PION")
elements.property(pion, "Description", "Pions, mesons made of up and down quarks, with one normal and one anti-quark.")
elements.property(pion, "Colour", 0xFFEEEE22)
elements.property(pion, "MenuSection", elem.SC_NUCLEAR)
elements.property(pion, "Properties", elem.TYPE_ENERGY + elem.PROP_LIFE_DEC + elem.PROP_RADIOACTIVE + elem.PROP_LIFE_KILL
+ elem.PROP_PHOTPASS)
elements.property(pion, "Temperature", 290)
elements.property(pion, "DefaultProperties",{["life"]=600})
local function pionUpdate(i,x,y,s,n)
local itmp = sim.partProperty(i, "tmp")
if itmp ~= 1 then
local theta = math.rad(math.random(0,359))
sim.partProperty(i, "vx", math.sin(theta)*3)
sim.partProperty(i, "vy", math.cos(theta)*3)
sim.partProperty(i, "tmp", 1)
end
end
elements.property(pion, "Update", pionUpdate)