with this script (it was originally made to learn how to use keypress events) you are able to control the speed and the direction of energy particles (NEUT, ELEC, PHOT). change the direction with arrow keys and the vx/vy speed with J (+0.1) and K (-0.1). the speed is updated only after pressing an arrow key.
local epup = false
local epdown = false
local epright = false
local epleft = false
local active = true
local vnum = 1
local epdir = ""
local hud = 1
function control(key,dkey,_,event)
if dkey == 273 then --up arrow
epup = true
epdown = false
epright = false
epleft = false
active = true
end
if dkey == 274 then --down arrow
epup = false
epdown = true
epright = false
epleft = false
active = true
end
if dkey == 276 then --right arrow
epup = false
epdown = false
epright = true
epleft = false
active = true
end
if dkey == 275 then --left arrow
epup = false
epdown = false
epright = false
epleft = true
active = true
end
if event==1 then
if key == "j" then
vnum=vnum+0.1
end
if key == "m" then
vnum=vnum-0.1
end
if key == "h" and hud==1 then
tpt.unregister_step(status)
hud=0
else
if key == "h" and hud==0 then
tpt.register_step(status)
hud=1
end
end
end
end
function contr(i,x,y,s,n)
if active then
if epup then
tpt.set_property("vy",-vnum)
tpt.set_property("vx",0)
pdir = "up"
active = false
end
if epdown then
tpt.set_property("vy",vnum)
tpt.set_property("vx",0)
pdir = "down"
active = false
end
if epright then
tpt.set_property("vy",0)
tpt.set_property("vx",-vnum)
pdir = "left"
active = false
end
if epleft then
tpt.set_property("vy",0)
tpt.set_property("vx",vnum)
epdir = "right"
active = false
end
end
end
function status()
tpt.drawtext(155,5,"Energy particle speed:",0,255,0)
tpt.drawtext(260,5,vnum)
tpt.drawtext(285,5,"Direction:",0,255,0)
tpt.drawtext(332,5,epdir)
end
tpt.register_step(status)
tpt.element_func(contr,tpt.el.phot.id)
tpt.element_func(contr,tpt.el.neut.id)
tpt.element_func(contr,tpt.el.elec.id)
tpt.register_keypress(control)
--By MrSalit0s
thanks! i will make an animated gif and add it to the first post then :)
thanks again ^^ this is definitely better than the program i used before to capture gif's.
This is amazing, you are capable of many things, by far. +1'ed your rep, and I may try this soon, if I have time.
okay, these things have changed now. don't know why i used parentheses here
Just tried this out, awesome work, man.