Extra Explosives

  • DorkyBobster
    1st Dec 2015 Member 3 Permalink

    Here is a script that I have been working on. It uses a couple of other people's work, but I am a beginner at using Lua, and can anyone tell me if it works?:

     


    local dorkybobster = elements.allocate("EXTR" , "EXPL")
    elements.element(dorkybobster, elements.element(elements.DEFAULT_PT_SNOW))
    elements.property(dorkybobster, "Name" , "EXPL")
    elements.property(dorkybobster, "Description" , "Basic Explosive, possibly strong.")
    elements.property(elements.dorkybobster_PT_EXPL, "Colour", 0x003486)
    elements.property(elements.dorkybobster_PT_EXPL, "MenuVisible", 1)
    elements.property(elements.dorkybobster_PT_EXPL, "MenuSection", elem.SC_EXPLOSIVE)
    elements.property(elements.dorkybobster_PT_EXPL, "Gravity", 0.1000000001419012) --approximately the WATR value
    elements.property(elements.dorkybobster_PT_EXPL, "Flammable", 1)
    elements.property(elements.dorkybobster_PT_EXPL, "Explosive", 0.30)
    elements.property(elements.dorkybobster_PT_EXPL, "Loss", 0.94999998807907) -- the same value as WATR
    elements.property(elements.dorkybobster_PT_EXPL, "AirLoss", 0.98) -- approx water value
    elements.property(elements.dorkybobster_PT_EXPL, "AirDrag", 0.009) -- approx watr value
    elements.property(elements.dorkybobster_PT_EXPL, "Advection", 0.6) -- rounded watr value
    elements.property(elements.dorkybobster_PT_EXPL, "Weight", 90)
    elements.property(elements.dorkybobster_PT_EXPL, "Diffusion", 0) -- watr value
    elements.property(elements.dorkybobster_PT_EXPL, "Falldown", 2) -- watr value
    elements.property(elements.dorkybobster_PT_EXPL, "Name", "EXPL")
    elements.property(elements.dorkybobster_PT_EXPL, "State", 2) -- watr value
    elements.property(elements.dorkybobster_PT_EXPL, "Temperature", 250)
    elements.property(elements.dorkybobster_PT_EXPL, "HighTemperature", 421.15)
    elements.property(elements.dorkybobster_PT_EXPL, "HighTemperatureTransition", elements.dorkybobster_PT_NBLE)
    elements.property(elements.dorkybobster_PT_EXPL, "LowTemperature", 210.15)
    elements.property(elements.dorkybobster_PT_EXPL, "LowTemperatureTransition", elements.dorkybobster_PT_RBDM)
    elements.property(elements.dorkybobster_PT_EXPL, "Hardness", 20)-- watr value
    NU = function(i, x, y, s, n)
     local clife = tpt.get_property('life', x, y)
     local tempk = tpt.get_property('temp', x, y)
     if clife > 1 then
      for cx = -1, 1, 2 do
       for cy = -1, 1, 2 do
        if tpt.get_property('type', x+cx, y+cy) ~= EXPLOSIVE then 
         tpt.create(x + cx, y + cy, 'fire')
         tpt.create(x + cx, y + cy, 'plsm')
         tpt.create(x + cx, y + cy, 'smke')
        end
       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) == elem.DEFAULT_PT_SNOW or tpt.get_property('type',x + cx,y + cy) == elem.DEFAULT_PT_PLSM or tempk >= 800 then
         tpt.set_property('life', 3500, x, y)
         return true
        end
       end
      end
     end
     if tempk < 210.15 then
      tpt.set_property('type', 'RBDM', x, y)
     end
     if tempk > 543.15 and clife == 0 then
      tpt.set_property('type', 'NBLE', x, y)
     end
    end
    local dorkybobster = elements.allocate("EXTR" , "ITDR")
    elements.allocate(dorkybobster, elements.element(elements_DEFAULT_THDR))
    elements.property(dorkybobster, "Name" , "ITDR")
    elements.property(dorkybobster, "Description" , "Improved Thunder. Lasts longer.")
    end
    local thdr_copy = elements.allocate("EXTR", "THDR")
    elements.element(elements.dorkybobster_PT_THDR, elements.element(elements.DEFAULT_PT_THDR))
    elements.property(elements.dorkybobster_PT_B, "Name", "ITDR")
    elements.property(elements.dorkybobster_PT_B, "Description", "Improved Thunder.")
    elements.property(elements.dorkybobster_PT_B, "Colour", 0xFFB9FEF7)
    elements.property(elements.dorkybobster_PT_B, "MenuSection", 5)
    elements.property(elements.dorkybobster_PT_B, "Gravity", 0)
    elements.property(elements.dorkybobster_PT_B, "Flammable", 0)
    elements.property(elements.dorkybobster_PT_B, "Explosive", 0)
    elements.property(elements.dorkybobster_PT_B, "Loss", 0.15)
    elements.property(elements.dorkybobster_PT_B, "AirLoss", 0.96)
    elements.property(elements.dorkybobster_PT_B, "AirDrag", 0.03)
    elements.property(elements.dorkybobster_PT_B, "Advection", 2)
    elements.property(elements.dorkybobster_PT_B, "Weight", 32)
    elements.property(elements.dorkybobster_PT_B, "Diffusion", 0)
    elements.property(elements.dorkybobster_PT_B, "Falldown", 0)
    ITDRUpdate = 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, 'thdr')
     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', 300, x, y)
     return true
     end
     end
     end
     end
    end
    tpt.element_func(ITDRUpdate, tpt.element('itdr'))

     

    function growth(i,x,y,s,n)
    type=tpt.get_property("type",x+math.random(-1,1),y+math.random(-1,1))
    if type==tpt.el.thdr.id then
    tpt.parts[i].type=tpt.el.hygn.id
    end
    end

    tpt.element_func(growth,tpt.el.thdr.id)

  • ChargedCreeper
    1st Dec 2015 Member 0 Permalink

    Your script appears to have been cut off. You should use Pastebin for pasting code.

  • yocheese
    2nd Dec 2015 Member 3 Permalink

    error: <eof> expected it near 'end'

  • DorkyBobster
    2nd Dec 2015 Member 0 Permalink

    @yocheese (View Post)

     What does that mean? I am a beginner at using Lua and I started about 2 days ago...

  • rdococ
    3rd Dec 2015 Member 0 Permalink

    I can't believe nobody said this. Can't you test it yourself? If you can't, I'll tell you how, I guess.

    1. Open TPT.
    2. Press either ` for British or ~ for American keyboards. I don't know about other keyboards.
    3. Call the dofile function by typing dofile(insert filename here in single or double quotes)
    4. If it doesn't work, one of five possible things have happened.
      1. The filename is mispelled.
      2. The file doesn't exist.
      3. You could have forgot the quotes.
      4. You literally typed "insert filename here in single or double quotes."
      5. Or you could have mistaken the parentheses as noting a note while reading this.
    Edited 2 times by rdococ. Last: 3rd Dec 2015
  • Shadow87879
    2nd Apr 2016 Member 0 Permalink

    ayy lmao