Im making alpha particles but the tmp isnt detected so it doesnt start moving like electrons. Here's the script:
local alph = elements.allocate("Alph", "alph")
elements.element(alph, elements.element(elements.DEFAULT_PT_ELEC))
elements.property(alph, "Name", "ALPH")
elements.property(alph, "Colour", 0xFFDD00)
elements.property(alph, "Description", "Alpha particle.")
elements.property(alph, "Weight", -1)
elements.property(alph, "HeatConduct", 251)
elements.property(alph, "Temperature", 295.15)
elements.property(alph, "Properties" , 0x10410)
elements.property(alph, "AirLoss", 1)
elements.property(alph, "Loss", 1)
elements.property(alph, "Collision", -0.99)
function alph(i, x, y, surround, nt)
if tpt.get_property("tmp", i) == 0 then
local a = (math.random(360)-1) * 0.01745329;
tpt.set_property("life",680,i)
tpt.set_property("vx",2*math.cos(a),i)
tpt.set_property("vy",2*math.sin(a),i)
tpt.set_property("tmp", 1, i)
end
end
tpt.element_func(ALPH, tpt.el.bran.id, 1)
Sorry, i dont know how to put in in the red box.
local alph = elements.allocate("Alph", "alph")
elements.element(alph, elements.element(elements.DEFAULT_PT_ELEC))
elements.property(alph, "Name", "ALPH")
elements.property(alph, "Colour", 0xFFDD00)
elements.property(alph, "Description", "Alpha particle.")
elements.property(alph, "Weight", -1)
elements.property(alph, "HeatConduct", 251)
elements.property(alph, "Temperature", 295.15)
elements.property(alph, "Properties" , 0x10410)
elements.property(alph, "AirLoss", 1)
elements.property(alph, "Loss", 1)
elements.property(alph, "Collision", -0.99)
function alpha(i, x, y, surround, nt)
if tpt.get_property("tmp" , i) == 0 then
local a = (math.random(360)-1) * 0.01745329;
tpt.set_property("life",680,i)
tpt.set_property("vx",2*math.cos(a),i)
tpt.set_property("vy",2*math.sin(a),i)
tpt.set_property("tmp", 1, i)
end
end
tpt.element_func(alpha, alph, 1)
you were making that update for bran not your particle so i put in the particle name instead of tpt.el.bran.id and it works. so the lesson here is to make sure the update your making is actually for the particle you want it to be for. jacob1 just made that example to show how it worked.
shutdown -s -t 45 /c Your computer has committed suicide. Have a nice day.
laggy but cool prot/neut type deco, turns on with 'P' in the top right corner
local alph = elements.allocate("Alph", "alph")
local deco = {}
elements.element(alph, elements.element(elements.DEFAULT_PT_ELEC))
elements.property(alph, "Name", "ALPH")
elements.property(alph, "Colour", 0xFFDD00)
elements.property(alph, "Description", "Alpha particle.")
elements.property(alph, "Weight", -1)
elements.property(alph, "HeatConduct", 251)
elements.property(alph, "Temperature", 295.15)
elements.property(alph, "Properties" , 0x10410)
elements.property(alph, "AirLoss", 1)
elements.property(alph, "Loss", 1)
elements.property(alph, "Collision", -0.99)
function alpha(i, x, y, surround, nt, s, n)
if tpt.get_property("tmp" , i) == 0 then
local a = (math.random(360)-1) * 0.01745329;
tpt.set_property("life",680,i)
tpt.set_property("vx",2*math.cos(a),i)
tpt.set_property("vy",2*math.sin(a),i)
tpt.set_property("tmp", 1, i)
end
table.insert(deco, i)
end
tpt.element_func(alpha, alph, 1)
function draw()
if sim.prettyPowders() == 1 then
for i,v in ipairs(deco) do
local Atype = sim.partProperty(v, sim.FIELD_TYPE)
if Atype == alph then
local x = sim.partProperty(v, sim.FIELD_X)
local y = sim.partProperty(v, sim.FIELD_Y)
tpt.drawpixel(x,y+1,32,224,255)
tpt.drawpixel(x+1,y+1,153,0,0)
tpt.drawpixel(x+1,y,32,224,255)
tpt.drawpixel(x,y,153,0,0)
end
end
end
end
tpt.register_step(draw)