My first Lua element NEON

  • mrsalit0s
    5th Aug 2012 Member 0 Permalink

    @ultibore (View Post)

     dunno then..

     

    @boxmein (View Post)

    cool :D i made something like that before, but it only shuffles the colours. i've also shorten the code a bit

    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

    local colour={0xFFAA0000,0xFFFF6600,0xFFFFFF00,0xFF00FF00,0xFF00FFFF,0xFF0000FF,0xFF9900CC}
    local none=0x00242424

    function neon(i,x,y,s,n)
        if tpt.get_property("tmp",i)== 0 then
            tpt.set_property("tmp",1,i)
        end
        if tpt.get_property("tmp2",i)== 1 then
            tpt.set_property("life",150,i)
            tpt.set_property("tmp2",0,i)
        end
        if tpt.parts[i].life<=0 then
            tpt.set_property("dcolour",none,i)
        end
    end

    function neonsprk(i,x,y,s,n)
    local ntmp=tpt.get_property("tmp",tpt.el.bran.id)
    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)==ntmp then
                tpt.set_property("dcolour",colour[ntmp],i)
                tpt.set_property("tmp2",1,i)
            end
            if tpt.get_property("tmp",i)==8 then
                tpt.set_property("dcolour",colour[math.random(1,7)],i)
                tpt.set_property("tmp2",1,i)
            end
        end
    end

    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)
    tpt.element_func(neon,tpt.el.bran.id)
    tpt.element_func(neonsprk,tpt.el.sprk.id)

  • mniip
    5th Aug 2012 Developer 0 Permalink
    thing 1:
    local colour={0xFFAA0000,0xFFFF6600,0xFFFFFF00,0xFF00FF00,0xFF00FFFF,0xFF0000FF,0xFF9900CC}

    thing 2:
    use locals
  • mrsalit0s
    5th Aug 2012 Member 0 Permalink

    @mniip (View Post)

    okay, thanks for the advice

  • soapie
    10th Aug 2012 Member 0 Permalink

    how u get it???

  • mrsalit0s
    11th Aug 2012 Member 0 Permalink

    @kaiwarden (View Post)

    copy the code from the first post --> @mrsalit0s (View Post) into your text editor, save it as autorun.lua and put the file into your powder toy directory. you could also use cracker64's script manager https://powdertoy.co.uk/Discussions/Thread/View.html?Thread=14596

    but then you shouldn't save the file as autorun.lua. name it neon.lua then.

     

     

  • dnerd
    11th Aug 2012 Member 0 Permalink

    I freaking love it. If this could be added to the main version i would burst into sparkles.

  • MZproductions
    23rd Aug 2012 Member 0 Permalink

    Why bran? Cuz when i change the 'bran' into something else, the element is not visible. PLZ answer. :(

  • mrsalit0s
    23rd Aug 2012 Member 0 Permalink

    BRAN is an unused element slot. if you changed it to other life elements it won't work. don't know how other elements would behave if you use this script with them. could be that its not working with some.

  • MZproductions
    23rd Aug 2012 Member 0 Permalink

    @mrsalit0s (View Post)

     Okay. thanks. :)

  • GAPDaTsar
    4th Sep 2012 Member 0 Permalink

    For function neon(i,x,y,s,n) it says I need "end" after that code and for  if tpt.get_property("tmp",i)== 0 then I have to put "end" after that too.  Then for local ntmp=tpt.get_property("tmp",tpt.el.bran.id)
    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 It just gives me things says "Element does not exist" or "End expected near something" things.  Why does it do that?  I want to know why it refuses those lines of code from working.