I'm trying to create a PCLN like particle in Lua in which it works exactly like PCLN but It won't work; how do I make this particle activate all connected to it when sparked and how do i make the delay until it stops creating PHOT to 5 seconds?
Here's the code that I have made:
--Light Emitting Diode
LED = elements.allocate("STBL", "LED") --properties
elements.element(LED, elements.element(elements.DEFAULT_PT_LCRY))
elements.property(LED, "Name", "LED")
elements.property(LED, "Description", "LED. Emits light when sparked.")
elements.property(LED, "Colour", 0xFFE9FE4B)
elements.property(LED, "MenuSection", 1)
elements.property(LED, "Weight", 100)
elements.property(LED, "Gravity", 0)
elements.property(LED, "Properties", elements.ST_SOLID + elements.TYPE_SOLID)
elements.property(LED, "Flammable", 0)
elements.property(LED, "Explosive", 0)
function funcled(i,x,y,s,n)
local mathx = math.random(-1,1)
local mathy = math.random(-1,1)
local temp = tpt.get_property("temp", i)
local life = tpt.get_property("life",i)
local etype = tpt.get_property("type",x+mathx,y+mathy)
if etype == elements.DEFAULT_PT_SPRK then
local rand = math.random(1,2)
tpt.set_property("life",10, i)
for i = -1,1,1 do
for i2 = -1,1,1 do
local phot = tpt.get_property("type",x+i,y+i2)
tpt.create(x+i, y+i2,"PHOT")
tpt.set_property("temp", temp, x+i, y+i2)
end
end
end
end
tpt.element_func(funcled, tpt.element("LED"))
--
I made this:
I fixed the error message problem:
local a = elements.allocate("SOMETHING" , "LOLOL")
elements.element(elements.SOMETHING_PT_LOLOL, elements.element(elements.DEFAULT_PT_TTAN))
elements.property(elements.SOMETHING_PT_LOLOL, "Name" , "LOLOL")
elements.property(elements.SOMETHING_PT_LOLOL, "Description" , "I have no clue")
function SOMEUPDATE(i,x,y,s,n)
local xo = math.random(-5,5) local yo = math.random(-5,5)
if tpt.get_property("type", x + xo, y + yo) ~= 0 then
if tpt.get_property("tmp", x + xo, y + yo) == 1 then
tpt.set_property("tmp", 1, x, y)
end
if tpt.get_property("tmp", x, y) == 1 then
tpt.create(x + math.random(-1,1), y + math.random(-1,1), 'phot')
end
end
end
tpt.element_func(SOMEUPDATE,elements.SOMETHING_PT_LOLOL)
If a particle around it has a tmp of 1 then it sets it off creating PHOT and it also makes the surrounding particles have a tmp of 1 setting them off so I'm not sure if that helps.
Thank you so much! But how do i make it turn off?
I will make it so you can shut it on and off as much as you like in the morning
I have done that but it keep detecting SPRK from all the sources around it and some turn off but others dont.
Okay I Made it so it turns off when sparked:
local a = elements.allocate("SOMETHING" , "LOLOL")
elements.element(elements.SOMETHING_PT_LOLOL, elements.element(elements.DEFAULT_PT_TTAN))
elements.property(elements.SOMETHING_PT_LOLOL, "Name" , "LOLOL")
elements.property(elements.SOMETHING_PT_LOLOL, "Description" , "I have no clue")
function SOMEUPDATE(i,x,y,s,n)
local xo = math.random(-5,5) local yo = math.random(-5,5)
if tpt.get_property("type", x + xo, y + yo) ~= 0 then
if tpt.get_property("tmp", x + xo, y + yo) == 1 then
tpt.set_property("tmp", 1, x, y)
end
if tpt.get_property("tmp", x, y) == 1 then
tpt.create(x + math.random(-1,1), y + math.random(-1,1), 'phot')
function sprk(i,x,y,s,n)
if tpt.get_property("ctype", x, y) == elements.SOMETHING_PT_LOLOL then
tpt.set_property("tmp", 0, x, y)
end
end
tpt.element_func(sprk,tpt.el.sprk.id)
end
end
end
tpt.element_func(SOMEUPDATE,elements.SOMETHING_PT_LOLOL)