Atom Bomb Lua Script

  • QuentinADay
    13th Apr 2014 Member 0 Permalink

    local a = elements.allocate("NOBODY" , "HHHH")
    elements.element(elements.NOBODY_PT_HHHH, elements.element(elements.DEFAULT_PT_BCOL))
    elements.property(elements.NOBODY_PT_HHHH, "Name" , "ATMB")
    elements.property(elements.NOBODY_PT_HHHH, "Description" , "Atom Bomb.")
    elements.property(elements.NOBODY_PT_HHHH, "MenuSection" , 5)
    elements.property(elements.NOBODY_PT_HHHH, "Gravity" , 0)
    elements.property(elements.NOBODY_PT_HHHH, "Falldown" , 0)
    elements.property(elements.NOBODY_PT_HHHH, "Flammable" , 1)
    elements.property(elements.NOBODY_PT_HHHH, "Explosive" , 1)
    elements.property(elements.NOBODY_PT_HHHH, "Diffusion" , 0)
    elements.property(elements.NOBODY_PT_HHHH, "Weight" , 100)
    elements.property(elements.NOBODY_PT_HHHH, "Advection" , 0.05)
    elements.property(elements.NOBODY_PT_HHHH, "AirLoss" , 0.95)
    elements.property(elements.NOBODY_PT_HHHH, "Loss" , 0.15)
    elements.property(elements.NOBODY_PT_HHHH, "Temperature" , 295.15)
    elements.property(elements.NOBODY_PT_HHHH, "HeatConduct" , 255)
    elements.property(elements.NOBODY_PT_HHHH, "MenuVisible" , 1)
    HHHHUpdate = function(i, x, y, s, n)
    local clife = tpt.get_property('life', x, y)
    if clife > 1 then
    for cx = -1, 1, 2 do
    for cy = -1, 1, 2 do
    tpt.create(x + cx, y + cy, 'ergy')
    end
    end
    tpt.set_property('life', clife - 1, x, y)
    elseif clife == 1 then
    tpt.set_property('type', 0, x, y)
    elseif s > 0 then
    for cx = -1, 1, 2 do
    for cy = -1, 1, 2 do
    if tpt.get_property('type', x + cx, y + cy) == 4 or tpt.get_property('type', x + cx, y + cy) == 49 then
    tpt.set_property('life', 145, x, y)
    return true
    end
    end
    end
    end
    end
    tpt.element_func(HHHHUpdate, tpt.element('atmb'))

    local a = elements.allocate("NOBODY" , "ERGY")
    elements.element(elements.NOBODY_PT_ERGY, elements.element(elements.DEFAULT_PT_NEUT))
    elements.property(elements.NOBODY_PT_ERGY, "Name" , "ERGY")
    elements.property(elements.NOBODY_PT_ERGY, "Description" , "High temperature Neutron")
    elements.property(elements.NOBODY_PT_ERGY, "Temperature" , math.huge)
    elements.property(elements.NOBODY_PT_ERGY, "Gravity" , 0)
    elements.property(elements.NOBODY_PT_ERGY, "Falldown" , 0)
    elements.property(elements.NOBODY_PT_ERGY, "Advection" , 0)
    elements.property(elements.NOBODY_PT_ERGY, "MenuSection" , 10)
    elements.property(elements.NOBODY_PT_ERGY, "AirLoss" , 1)
    elements.property(elements.NOBODY_PT_ERGY, "Loss" , 1)
    elements.property(elements.NOBODY_PT_ERGY, "Collision" , -0.99)
    elements.property(elements.NOBODY_PT_ERGY, "Weight" , -1)
    elements.property(elements.NOBODY_PT_ERGY, "HeatConduct" , 251)
    elements.property(elements.NOBODY_PT_ERGY, "Properties" , 0x14410)
    elements.property(elements.NOBODY_PT_ERGY, "MenuVisible" , 1)
    function update_energy(i, x, y, surround, nt)
    if tpt.get_property("tmp",i) == 0 then
    local r = (math.random(128)+127) / 127;
    local a = (math.random(360)-1) * 0.01745329;
    tpt.set_property("life",math.random(480)+479,i)
    tpt.set_property("vx",r*math.cos(a),i)
    tpt.set_property("vy",r*math.sin(a),i)

    tpt.set_property("tmp", 1, i)
    end
    end
    tpt.element_func(update_energy,elements.NOBODY_PT_ERGY, 1)

     

     

    Its a bit buggy I'm not really sure why but other wise its pretty cool

  • KydonShadow
    13th Apr 2014 Member 0 Permalink

    it is a bit buggy... <_<

  • QuentinADay
    13th Apr 2014 Member 0 Permalink

    If you turn the advection up it explodes much better but it also gets much more buggy...

  • CeeJayBee
    13th Apr 2014 Member 0 Permalink

    Question: Why NOBODY_PT_*?

  • QuentinADay
    13th Apr 2014 Member 0 Permalink

    Idk i just usually use it when i have nothing else in mind

    Edited once by QuentinADay. Last: 13th Apr 2014
  • boxmein
    13th Apr 2014 Former Staff 0 Permalink
    You could just do this:
    local elementID = elements.allocate("QuentinADay", "ERGY")
    elements.property(elementID, "Colour", 0xFFFF00FF)
  • CeeJayBee
    13th Apr 2014 Member 0 Permalink
    @QuentinADay (View Post)
    Oh, right. I had an underlying feeling it was copied from the other lua scripter Nobody, who uses NOBODY_PT_*. Sorry I doubted you :P
  • QuentinADay
    14th Apr 2014 Member 0 Permalink

    lol ya i think i might have picked it up form them and just started using it...