could you discribe the error you got with the graphics function? for me it works without problems so far.. but for now I have it taken out and add it later again.
yes i would be interested in your adaptation. maybe i'll add it to my script
thanks, i'll work on it :)
tpt.el.bran.menu=1
tpt.el.bran.enabled=1
tpt.el.bran.menusection=5
tpt.el.bran.name="NEON"
tpt.el.bran.description="Neon gas - glows in contact with electricity"
tpt.el.bran.color=0X00242424
tpt.el.bran.gravity=0
tpt.el.bran.diffusion=1
tpt.el.bran.advection=2
tpt.el.bran.properties=0x4828
tpt.el.bran.flammable=0
tpt.el.bran.heat=295
tpt.el.bran.weight=0
tpt.el.bran.airloss=1
usercolor= 0xFFFF0000
colour= {}
colour["8"]=0xFFFF0000
colour["9"]= 0xFFFF0000
colour["10"]=0xFFFF0000
function neon(i,x,y,s,n)
if tpt.get_property("tmp2",i)== 1 then
tpt.set_property("life",200,i)
tpt.set_property("tmp2",0,i)
end
if tpt.parts[i].life<=0 then
if tpt.get_property("tmp",i)==7 then
if tpt.get_property("dcolour",i) ~= 0X00242424 then
usercolor = tpt.get_property("dcolour",i)
end
end
if tpt.get_property("tmp",i)>7 then
local b = tpt.get_property("tmp",i)
if tpt.get_property("dcolour",i) ~= 0X00242424 then
colour[b] = tpt.get_property("dcolour",i)
end
end
tpt.set_property("dcolour",0X00242424,i)
end
end
function neonsprk(i,x,y,s,n)
type=tpt.get_property("ctype",x+math.random(-1,1),y+math.random(-1,1))
if tpt.get_property("ctype",i)==tpt.el.bran.id then
if tpt.get_property("tmp",i)==0 then
tpt.set_property("dcolour",0xFFFF0000,i) --red
tpt.set_property("tmp2",1,i)
end
if tpt.get_property("tmp",i)==1 then
tpt.set_property("dcolour",0xFFFF6600,i) --orange
tpt.set_property("tmp2",1,i)
end
if tpt.get_property("tmp",i)==2 then
tpt.set_property("dcolour",0xFFFFFF00,i) --yellow
tpt.set_property("tmp2",1,i)
end
if tpt.get_property("tmp",i)==3 then
tpt.set_property("dcolour",0xFF00FF00,i) --green
tpt.set_property("tmp2",1,i)
end
if tpt.get_property("tmp",i)==4 then
tpt.set_property("dcolour",0xFF00FFFF,i) --aqua
tpt.set_property("tmp2",1,i)
end
if tpt.get_property("tmp",i)==5 then
tpt.set_property("dcolour",0xFF0000FF,i) --blue
tpt.set_property("tmp2",1,i)
end
if tpt.get_property("tmp",i)==6 then
tpt.set_property("dcolour",0xFF9900CC,i) --purple
tpt.set_property("tmp2",1,i)
end
if tpt.get_property("tmp",i)==7 then
tpt.set_property("dcolour", usercolor,i) -- user editable color
tpt.set_property("tmp2",1,i)
end
if tpt.get_property("tmp",i) > 7 then
local tmplocal= tpt.get_property("tmp",i)
tpt.set_property("dcolour", colour[tmplocal],i)
tpt.set_property("tmp2",1,i)
end
end
end
tpt.element_func(neon,tpt.el.bran.id)
tpt.element_func(neonsprk,tpt.el.sprk.id)
-- I don't know what error reading there is, but my powder toy allways closes down when I implement the graphics function (I replaced the coding untill I found that the graphic part caused the crashing of my TPT) . It might be because I use TPT legacy, wich tends to miraculously close for some strange reasons ( fiddling with stickman did the same) . I also want to note that I used some bad coding ( tmp 7 apart and 8 and above apart, even though they react the same) , but the table has the tendency to ignore it's first value and behaves strangely every now and then, whilas the single stored value shows no errors at all. The contributions of the tablevalues are also unnecessary but for some reason they diminish the strange reactions ( not coloring red) from their tmp-neons so i just left them. I also didn't bother to use local variables, for equal reasons, though I know how to use good coding, it seemed to react smoother if I didn't so I stopt bothering. PS This is my first thing in LUA, (I'm familiar with other codings whatsoever) oh and great idea ofcourse
Well, you can't just go and write stuff like 'tpt.set_property("dcolour", usercolor,i) -- user editable color'..
Maybe that's the error.
You can keep the '-- user editable color'..', but 'usercolor' isn't accepted as a color. Maybe you should change it to white, which is 0xFFFFFFFF, or to 'no changes', which is 0x00000000 (the first '00' makes the color have no effect).
the error is not included, by the way usercolor is a variable, it wouldn't have been bad to set it to white but that doesn't matter. Giving a variable for a dcolour works (I tested it) jus like anyone with programming experience would expect. another thing if you tipe -- in a lua coding then you are placing a comment that will not be exerted.
usercolor starts of (as you could read) as 0xFFFF0000 (red) but can be changed by the neon function when a user utilises the dcolour panel.
I don't mind criticism, but if you accuse me of lazy and irresponsable coding (not saying I never do) , give a thorough and thought through explanation, otherwise it comes down to trolling.
I also forgot to mention before that if you color an uncharged neon (wich will cause it to fall back to base color in the next frame) it will automatically change dcolour (maybe the easiest way)). (not that you wouldn't see it for yourself sooner or later, but it is always nice to now from the start)
I really want to, but the exact piece of code seems to be removed already , it was called neongraph, and it was meant to return a certain colour ( it was a function with only with a return, containing some sort of color description not in hexadecimal, but with a lot of different numbers: about 4 times 30 (..,..,..,30,30,30,30) at the end. You should ask mrsalit0s , he might still got it , if else, sorry
function neongraphics(i, colr, colg, colb)
return 1,0x00022110,30,30,30,30,30,30,30,30
end
tpt.graphics_func(neongraphics,tpt.el.bran.id)
here is the piece of code i removed. i tested it a minute ago with my script and it still works..
EDIT: added it again to the first post with a screenshot
I just wanted to help, you don't have to act like that >_>
Are you the king of the world or something?
You're a person like anyone else.
No point in acting like that.
Edit: apparently you know more lua than me, but that doesn't mean you can just arrive to the forums and act like the one which knows everything above everyone else.
You just came and I immediatly started disliking your attitude -.-
I'm sorry to say, it still causes my TPT legacy to close, I truly beleive it to be correctly written, but I guess TPT legacy still has some bugs that are already solved in normal TPT or something may be wrong with my version (as I mentioned before, it also acts strange when I start fiddling with my stickman)
asd = 0
len = 5 -- Edit this to change rainbow length!
function neonrainbow()
if asd % len == 0 then
tpt.set_property("tmp", asd / len, "neon")
end
if asd == (6 * len) then
asd = 0
else
asd = asd + 1
end
end