Massive Gunpowder

  • Luezma
    17th Sep 2013 Member 1 Permalink

    Hello! This is my new material, MGUN. It explodes when sparked, when over or 200.0 degrees, and under 5.0 pressure, releasing a lot of pressure and making PLSM.

    It also have an explosion function, you can use if you want.

     

    local NBOMB = elements.allocate("LUEZMA", "BOMB")
    elements.element(elements.LUEZMA_PT_BOMB, elements.element(tpt.element("DUST")))
    elements.property(elements.LUEZMA_PT_BOMB, "Name", "MGUN")
    elements.property(elements.LUEZMA_PT_BOMB, "Description", "Massive gunpowder. Explodes when sparked, under high pressure or hot, creating too much pressure. Very destructive")
    elements.property(elements.LUEZMA_PT_BOMB, "Color", 0xE2CABD)
    elements.property(elements.LUEZMA_PT_BOMB, "MenuVisible", 1)
    elements.property(elements.LUEZMA_PT_BOMB, "MenuSection", 5)
    elements.property(elements.LUEZMA_PT_BOMB, "Advection", 0.6)
    elements.property(elements.LUEZMA_PT_BOMB, "AirDrag", 0.1)
    elements.property(elements.LUEZMA_PT_BOMB, "AirLoss", 0.6)
    elements.property(elements.LUEZMA_PT_BOMB, "Loss", 0.95)
    elements.property(elements.LUEZMA_PT_BOMB, "Collision", -0.2)
    elements.property(elements.LUEZMA_PT_BOMB, "Gravity", 0.25)
    elements.property(elements.LUEZMA_PT_BOMB, "Falldown", 1)
    elements.property(elements.LUEZMA_PT_BOMB, "Flammable", 10000)
    elements.property(elements.LUEZMA_PT_BOMB, "Explosive", 10000)
    elements.property(elements.LUEZMA_PT_BOMB, "Hardness", 4)
    elements.property(elements.LUEZMA_PT_BOMB, "Weight", 90)
    elements.property(elements.LUEZMA_PT_BOMB, "Temperature", 293.15)
    elements.property(elements.LUEZMA_PT_BOMB, "HeatConduct", 100)
    elements.property(elements.LUEZMA_PT_BOMB, "State", 1)
    elements.property(elements.LUEZMA_PT_BOMB, "Properties", 0x20504)

     

    local function explosion(x, y, s)
        for px = -1, 1 do
            for py = -1, 1 do
                tpt.create(x + px, y - py, "PLSM")
                local pressure = sim.pressure((x + px) / 4.0, (y + py) / 4.0)
                sim.pressure((x + px) / 4.0, (y + py) / 4.0, pressure + s * 10)
                sim.velocityX((x + px) / 4.0, y / 4.0, px * s)
                sim.velocityY((x + px) / 4.0, (y - py) / 4.0, -py * s)

            end
        end
    end

     

    local function NBMB_update(i, x, y, s, n)
        local r = 1
        if sim.pressure(x / 4.0, y / 4.0) >= 5.0 then

            explosion(x, y, 1)
            tpt.delete(i)
        elseif tpt.get_property("temp", i) >= 473.15 then
            explosion(x, y, 1)
            tpt.delete(i)
        end

    end

     

    tpt.element_func(NBMB_update, elements.LUEZMA_PT_BOMB)

     

    EDIT-1: Deleted explode when sparked code to reduce low FPS(still exploding when sparked)

     

    Please comment

    Edited 6 times by Luezma. Last: 28th Sep 2013
  • KOTOM
    18th Sep 2013 Member 0 Permalink

    I love this element, but it kills so much FPS...

  • evsey
    21st Sep 2013 Member 0 Permalink

    Im think that MGUN needs TPT Script manager? Im tryed it, and it worked! Yay! (english is not my primary language)

  • 006275
    21st Sep 2013 Member 0 Permalink

    how do you get it?

  • Luezma
    28th Sep 2013 Member 0 Permalink

    @KOTOM (View Post)

     I don't know how to reduce FPS load, I agree with you

  • DanDuncombe
    28th Sep 2013 Member 0 Permalink

    @Luezma (View Post)

     In my High Explosive mod, removing the spark-to-ignite code stopped the FPS drop.

  • KOTOM
    28th Sep 2013 Member 0 Permalink

    @DanDuncombe (View Post)

    I love Highly Explosive mod too.

  • Luezma
    29th Sep 2013 Member 0 Permalink

    @DanDuncombe (View Post)

     I fixed it and now runs pretty faster, thanks for the idea