Delay explosive - Lua Scripting

  • Antoine18
    28th Mar 2015 Member 0 Permalink

    DEXP: Delay explosive. Explodes on delay with life.

    Durations for explode:

    Life = 2 (instanty)

    Life = 30 (short moment)

    Life = 150 (average moment)

    Life = 300 (long moment)

    Life = >3000 (very long moment)

    Can also glow if got life.

    Properties of element: 

    - Start

    local DEXP = elements.allocate("ANTOINE", "DEXP")

    elements.element(elements.ANTOINE_PT_DEXP, elements.element(elements.DEFAULT_PT_DMND))

    elements.property(elements.ANTOINE_PT_DEXP, "Name", "DEXP")

    elements.property(elements.ANTOINE_PT_DEXP, "Description", "Delay Explosive. Creates violent explosions at duration if got life.")

    elements.property(elements.ANTOINE_PT_DEXP, "Color", 0x7F00FF)

    elements.property(elements.ANTOINE_PT_DEXP, "MenuSection", 10)

    elements.property(elements.ANTOINE_PT_DEXP, "Hardness", 102)

    elements.property(elements.ANTOINE_PT_DEXP, "HeatConduct", 151)

    elements.property(elements.ANTOINE_PT_DEXP, "Properties", elem.TYPE_SOLID + elem.PROP_LIFE_DEC)

    - End

    Function of element: 

    - Start

    local function dexpfunction(i, x, y, s, n)

    local life = tpt.get_property("life", i)

    if life == 1 or life <= -1 then

    tpt.set_pressure(x/4, y/4, 128)

    tpt.set_property("temp", math.huge, i)

    tpt.create(x + 1, y, "NEUT")

    tpt.create(x - 1, y, "NEUT")

    tpt.create(x, y - 1, "PROT")

    tpt.create(x, y + 1, "PROT")

    tpt.set_property("temp", math.huge, x + 1 , y)

    tpt.set_property("temp", math.huge, x - 1, y)

    tpt.set_property("temp", math.huge, x, y - 1)

    tpt.set_property("temp", math.huge, x, y + 1)

    tpt.set_property("type", "PLSM", i)

    tpt.set_property("life", 1000, i)

    end

    end

    tpt.element_func(dexpfunction, elements.ANTOINE_PT_DEXP)

    - End

    Graphics of element: 

    - Start

    local function dexpgraphics(i, colr, colg, colb)

    local life = tpt.get_property("life", i)

    if life >= 1 then

    return 1, ren.PMODE_FLAT + ren.FIRE_ADD + ren.DECO_FIRE, 255, 127, 0, 255, 255, 127, 0, 255

    end

    return 1, ren.PMODE_FLAT, 255, 127, 0, 255, 255, 127, 0, 255

    end

    tpt.graphics_func(dexpgraphics, elements.ANTOINE_PT_DEXP)

    - End

    I will sort all this: 

    local DEXP = elements.allocate("ANTOINE", "DEXP")

    elements.element(elements.ANTOINE_PT_DEXP, elements.element(elements.DEFAULT_PT_DMND))

    elements.property(elements.ANTOINE_PT_DEXP, "Name", "DEXP")

    elements.property(elements.ANTOINE_PT_DEXP, "Description", "Delay Explosive. Creates violent explosions at duration if got life.")

    elements.property(elements.ANTOINE_PT_DEXP, "Color", 0x7F00FF)

    elements.property(elements.ANTOINE_PT_DEXP, "MenuSection", 10)

    elements.property(elements.ANTOINE_PT_DEXP, "Hardness", 102)

    elements.property(elements.ANTOINE_PT_DEXP, "HeatConduct", 151)

    elements.property(elements.ANTOINE_PT_DEXP, "Properties", elem.TYPE_SOLID + elem.PROP_LIFE_DEC)

    local function dexpfunction(i, x, y, s, n)

    local life = tpt.get_property("life", i)

    if life == 1 or life <= -1 then

    tpt.set_pressure(x/4, y/4, 128)

    tpt.set_property("temp", math.huge, i)

    tpt.create(x + 1, y, "NEUT")

    tpt.create(x - 1, y, "NEUT")

    tpt.create(x, y - 1, "PROT")

    tpt.create(x, y + 1, "PROT")

    tpt.set_property("temp", math.huge, x + 1 , y)

    tpt.set_property("temp", math.huge, x - 1, y)

    tpt.set_property("temp", math.huge, x, y - 1)

    tpt.set_property("temp", math.huge, x, y + 1)

    tpt.set_property("type", "PLSM", i)

    tpt.set_property("life", 1000, i)

    end

    end

    tpt.element_func(dexpfunction, elements.ANTOINE_PT_DEXP)

    local function dexpgraphics(i, colr, colg, colb)

    local life = tpt.get_property("life", i)

    if life >= 1 then

    return 1, ren.PMODE_FLAT + ren.FIRE_ADD + ren.DECO_FIRE, 255, 127, 0, 255, 255, 127, 0, 255

    end

    return 1, ren.PMODE_FLAT, 255, 127, 0, 255, 255, 127, 0, 255

    end

    tpt.graphics_func(dexpgraphics, elements.ANTOINE_PT_DEXP)