New firework-like element BNMT

  • peeps
    19th Feb 2012 Member 3 Permalink
    or you can call it "burning metal" it splashes when contacts with anything,also a bit hot(3022.85 C),it creates random color.
    --------------------------------------------------------------------------
    here is the code:
    --------------------------------------------------------------------------
    tpt.el.bomb.name="BNMT"
    tpt.el.bomb.description="Burning Metal"

    math.randomseed(os.time())
    function splash(i, x, y, s, n)
    if tpt.parts[i].life==0 then
    tpt.parts[i].life=math.random(0,400)
    end
    if tpt.parts[i].tmp==0 then
    tpt.parts[i].tmp=1
    end
    for xpos=x-1,x+1,1 do
    for ypos=y-1,y+1,1 do
    if tpt.get_property("type",xpos,ypos)~=0 and tpt.get_property("type",xpos,ypos)~=tpt.el.bomb.id then
    if tpt.parts[i].life>=50 then
    if tpt.parts[i].ctype<2 then --change this to 3 and it will cause CRAZY fireworks<br/> tpt.delete(i)
    cindex=math.random(0,255)
    for ox=x-1,x+1,1 do
    for oy=y-1,y+1,1 do
    if tpt.get_property("type",ox,oy)==0 then
    tpt.create(ox,oy,tpt.el.bomb.id)
    tpt.set_property("life",tpt.parts[i].life/2,ox,oy)
    tpt.set_property("tmp",1,ox,oy)
    tpt.set_property("ctype",tpt.parts[i].ctype+1,ox,oy)
    tpt.set_property("vx",math.random(-8,8),ox,oy)
    tpt.set_property("vy",math.random(-8,8),ox,oy)
    tpt.set_property("temp",3300,ox,oy)
    tpt.set_property("dcolour",math.floor(math.sin(cindex*3.14159/127.5)*128+128)+math.floor(math.sin(cindex*3.14159/127.5+2.0944)*128+128)*0x100+math.floor(math.sin(cindex*3.14159/127.5+4.1888)*128+128)*0x10000+0xff000000,ox,oy)
    end
    end
    end
    end
    end
    end
    end
    end
    end
    tpt.element_func(splash, tpt.el.bomb.id,1)

    ------------------------------------------------------------------
    simply put it to Autorun.lua or save it in a new name
  • ArtMaster
    19th Feb 2012 Banned 0 Permalink
    This post is hidden because the user is banned
  • _kinloch_
    19th Jun 2012 Member 0 Permalink

    @peeps (View Post)

     I like it :)

  • boxmein
    19th Jun 2012 Former Staff 1 Permalink
    Improving even more on your post:

    tpt.el.bomb.name="BNMT"
    tpt.el.bomb.description="Burning Metal"

    math.randomseed(os.time())
    function splash(i, x, y, s, n)
    if tpt.parts[i].life==0 then
    tpt.parts[i].life=math.random(0,400)
    end

    if tpt.parts[i].tmp==0 then
    tpt.parts[i].tmp=1
    end

    for xpos=x-1,x+1,1 do
    for ypos=y-1,y+1,1 do

    if tpt.get_property("type",xpos,ypos)~=0 and tpt.get_property("type",xpos,ypos)~=tpt.el.bomb.id then

    if tpt.parts[i].life>=50 then
    if tpt.parts[i].ctype<2 then --change this to 3 and it will cause CRAZY fireworks <br/> tpt.delete(i)
    cindex=math.random(0,255)

    for ox=x-1,x+1,1 do
    for oy=y-1,y+1,1 do

    if tpt.get_property("type",ox,oy)==0 then

    tpt.create(ox,oy,tpt.el.bomb.id)

    tpt.set_property("life",tpt.parts[i].life/2,ox,oy)
    tpt.set_property("tmp",1,ox,oy)
    tpt.set_property("ctype",tpt.parts[i].ctype+1,ox,oy)
    tpt.set_property("vx",math.random(-8,8),ox,oy)
    tpt.set_property("vy",math.random(-8,8),ox,oy)
    tpt.set_property("temp",3300,ox,oy)
    tpt.set_property("dcolour",math.floor(math.sin(cindex*3.14159/127.5)*128+128)+math.floor(math.sin(cindex*3.14159/127.5+2.0944)*128+128)*0x100+math.floor(math.sin(cindex*3.14159/127.5+4.1888)*128+128)*0x10000+0xff000000,ox,oy)

    end
    end
    end
    end
    end
    end
    end
    end
    end
    end
    tpt.element_func(splash, tpt.el.bomb.id,1)
  • vertigo
    27th Jun 2012 Member 0 Permalink

    Dayum. A lot of indenting going on there XD

    Nice mod.