I got it to work.
tpt.el.elec.menusection=5
tpt.el.elec.color=0x9555ff
tpt.el.elec.description="Ball Lightning. Travels in strait lines and bounces of solids. It electrifies conductors. Explodes when Life=1."
tpt.el.elec.name="BLLT"
math.randomseed(os.time())
function ball_lightning(i,x,y,s,n)
if tpt.get_property("tmp",i)==0 then
tpt.set_property("life",math.random(50,150),i)
tpt.set_property("tmp",1,i)
end
for n = 1,50 do
xoff=math.random(-7,7)
yoff=math.sqrt((49)-(xoff^2))
if tpt.get_property("type",x+xoff,y+yoff)==0 then
tpt.create(x+xoff,y+yoff,"ligh")
tpt.set_property("life",4,x+xoff,y+yoff)
tpt.set_property("tmp",math.atan2(-yoff,xoff)/3.14159*180,x+xoff,y+yoff)
tpt.set_property("tmp2",1,x+xoff,y+yoff)
end
if tpt.get_property("type",x-xoff,y-yoff)==0 then
tpt.create(x-xoff,y-yoff,"ligh")
tpt.set_property("life",4,x-xoff,y-yoff)
tpt.set_property("tmp",math.atan2(yoff,-xoff)/3.14159*180,x-xoff,y-yoff)
tpt.set_property("tmp2",1,x-xoff,y-yoff)
end
end
if tpt.get_property("life",i)==1 then
for yoff=-38,38 do
for xoff=-math.sqrt((38^2)-(yoff^2)),math.sqrt((38^2)-(yoff^2)) do
if (x+xoff)>3 and (x+xoff)<608 and (y+yoff)>3 and (y+yoff)<380 then if tpt.get_property("type",x+xoff,y+yoff)==0 then
tpt.create(x+xoff,y+yoff,"plsm")
tpt.set_property("life",30,x+xoff,y+yoff)
tpt.set_pressure((x+xoff)/4,(y+yoff)/4,1,1,10)
end
end
end
end
tpt.delete(i)
end
end
tpt.element_func(ball_lightning,tpt.el.elec.id,1)