Stuck on scripting TPT

  • LiquidPlasma
    24th Nov 2018 Member 0 Permalink

    So I recently decided to have a go at creating custom elements. It was going well so far but I got stuck on something; how do I make a solid turn into a particle when it is under too much pressure? I used the code in the script "1.4b.lua" which comes with jacob1's mod for reference, copying lines from crystal, one of its breakable solids. But when my clay element breaks, it turns to stone, not broken clay. Below is my script.

     

    local function velocity(i,v,n) --*1
    local angle = math.random(1,n)*(2*math.pi/n)
    tpt.set_property("vx", v*math.cos(angle), i)
    tpt.set_property("vy", v*math.sin(angle), i)
    tpt.set_property("tmp", -1, i)
    end --*1

    local function attract(i,x,y,a) --*1
    sim.gravMap(x/4,y/4,a)
    end --*1

    local brgd = elements.allocate("TPT" , "BRGD")
    elements.element(brgd, elements.element(elements.DEFAULT_PT_BRMT))
    elements.property(brgd, "Name" , "BRGD")
    elements.property(brgd, "Description" , "Broken gold. Heavy powder.")
    elements.property(brgd, "Color", 0xffe100)
    elements.property(brgd, "Gravity", 0.5)
    elements.property(brgd, "AirDrag", 0.08)
    elements.property(brgd, "Weight", 97)
    elements.property(brgd, "Meltable", 1)
    elements.property(brgd, "HighTemperature", 1500)
    elements.property(brgd, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(elements.TPT_PT_BRGD, "Update", --*1
    function(i,x,y,s,nt) --1
    if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_GOLD then --2
    sim.partProperty(i, "type", elements.TPT_PT_BRGD)
    end --2
    end --1
    ) --*1

    local clay = elements.allocate("TPT" , "CLAY")
    elements.element(clay, elements.element(elements.DEFAULT_PT_BRCK))
    elements.property(clay, "Name" , "CLAY")
    elements.property(clay, "HeatConduct", 2)
    elements.property(clay, "Color", 0x788991)
    elements.property(clay, "Description" , "Clay.")
    elements.property(clay, "AirLoss", 0.2)
    elements.property(clay, "Hardness", 1)
    elements.property(clay, "HighPressure", 10.14)
    elements.property(clay, "HighPressureTransition", elements.TPT_PT_BRCL)

    local brcl = elements.allocate("TPT" , "BRCL")
    elements.element(brcl, elements.element(elements.DEFAULT_PT_STNE))
    elements.property(brcl, "Name" , "BRCL")
    elements.property(brcl, "Description" , "Broken clay.")
    elements.property(brcl, "Color", 0xa8bbc4)
    elements.property(brcl, "Gravity", 0.2)
    elements.property(brcl, "AirDrag", 0.08)
    elements.property(brcl, "Weight", 97)
    elements.property(brcl, "Meltable", 1)
    elements.property(brcl, "HighTemperature", 873)
    elements.property(brcl, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(elements.TPT_PT_BRCL, "Update", --*1
    function(i,x,y,s,nt) --1
    if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_CLAY then --2
    sim.partProperty(i, "type", elements.TPT_PT_BRCL)
    end --2
    end --1
    ) --*1

     

    I would also like to know how to modify existing elements, so I can make broken gold come from gold under too much pressure. I have checked the other threads asking for help with this to no avail. 

     

     

     

  • Florinite
    24th Nov 2018 Member 0 Permalink

    To get gold to break into BRGD, this is the code you need.

     

    elements.property(elements.DEFAULT_PT_GOLD, "HighPressure", -The pressure you want it to break at-)
    elements.property(elements.DEFAULT_PT_GOLD, "HighPressureTransition", elements.TPT_PT_BRGD)

     

    I'm not sure about your other problem, though.

  • LiquidPlasma
    25th Nov 2018 Member 0 Permalink

    Thanks. I assume for clay to break in to br. clay it would be same but replace GOLD with CLAY? I'll try that. Cheers for the help. I'll reply if it doesn't work for some reason.

     

    Edit:

    IT WORKED! GOLD TURNS TO BRGD NOW! THANKS! Also, I tried it with Clay and it failed. But I've learned something:- "elements.DEFAULT_PT_----" refers to a vanilla TPT element. But "elements.TPT_PT_----" refers to one of YOUR elements. I copied the lines you gave me and set the default part to TPT, and it worked. Clay turns to broken clay at high pressure! Thanks!

     

    Edit 2:

    Can you help me with burning? I made flash powder and flash wood, a solid alternative, and they burn quickly but not hot-ly. I'm not sure how to get something to burn at a specific temperature. I'd also like to know how to make something have a tnt-like explosion, with embr and things.

    Edited 2 times by LiquidPlasma. Last: 25th Nov 2018
  • Florinite
    25th Nov 2018 Member 0 Permalink

    Well, all higher burn temperatures require are a higher flammability value, preferably in the high 100's. As for a tnt-like burn effect, it's slightly more complicated, and you need a function. Luckily, the function is quite simple, and only is made of a few lines. I would recommend something close to the following:

     

    You need to replace the "TESTFLAME", the two "DEFAULT_PT_--"s, and the "stne" at the end.

     

    local function TESTFLAME(i, x, y)
    r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
    if r~= nil then
    if sim.partProperty(r, "type") == elem.DEFAULT_PT_FIRE and math.random(1,5) == 1 then
                    sim.partProperty(i, "type", elem.DEFAULT_PT_EQVE)
                    sim.partProperty(r, "type", elem.DEFAULT_PT_FIRE)
                    tpt.create(x+math.random(-1,1), y+math.random(-1,1), "embr")
                    tpt.create(x+math.random(-1,1), y+math.random(-1,1), "embr")
                    tpt.create(x+math.random(-1,1), y+math.random(-1,1), "embr")
                    end
                    end
                    end
    tpt.element_func(TESTFLAME, tpt.element('stne'))

     

    Unfortunately, I think that if you have elements that don't conduct heat, they can't change states. I might be wrong, though.

    Edited once by Florinite. Last: 29th Nov 2018
  • LiquidPlasma
    26th Nov 2018 Member 0 Permalink

    Not sure what I did wrong mate, but it didn't work. Had a couple of errors, missing characters etc, so fixed them and my elements just failed to load. No errors written, just nothing loaded. Disabled/enabled script 3 times and nothing. But I did manage to get hot fire by increasing flammability of FPDR/FLWD (Flash powder and flash wood). Thanks for that. I'm also looking to make an element DEST-Resistant, if you can do that.

     

    Also, I made an insulating gas and insulating liquid, set up the code, but they don't seem to want to boil. I'll post my code below;

     

    local function velocity(i,v,n) --*1
    local angle = math.random(1,n)*(2*math.pi/n)
    tpt.set_property("vx", v*math.cos(angle), i)
    tpt.set_property("vy", v*math.sin(angle), i)
    tpt.set_property("tmp", -1, i)
    end --*1

    local function attract(i,x,y,a) --*1
    sim.gravMap(x/4,y/4,a)
    end --*1

    local brgd = elements.allocate("TPT" , "BRGD")
    elements.element(brgd, elements.element(elements.DEFAULT_PT_BRMT))
    elements.property(brgd, "Name" , "BRGD")
    elements.property(brgd, "Description" , "Broken gold. Heavy powder.")
    elements.property(brgd, "Color", 0xffe100)
    elements.property(brgd, "Gravity", 0.5)
    elements.property(brgd, "AirDrag", 0.08)
    elements.property(brgd, "Weight", 99)
    elements.property(brgd, "Meltable", 1)
    elements.property(brgd, "HighTemperature", 1500)
    elements.property(brgd, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(elements.DEFAULT_PT_GOLD, "HighPressure", 20)
    elements.property(elements.DEFAULT_PT_GOLD, "HighPressureTransition", elements.TPT_PT_BRGD)
    elements.property(elements.TPT_PT_BRGD, "Update", --*1
    function(i,x,y,s,nt) --1
    if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_GOLD then --2
    sim.partProperty(i, "type", elements.TPT_PT_BRGD)
    end --2
    end --1
    ) --*1

    local brfe = elements.allocate("TPT" , "BRFE")
    elements.element(brfe, elements.element(elements.DEFAULT_PT_BRMT))
    elements.property(brfe, "Name" , "BRIR")
    elements.property(brfe, "Description" , "Broken iron. Quite heavy powder.")
    elements.property(brfe, "Color", 0x7c7c7c)
    elements.property(brfe, "Gravity", 0.45)
    elements.property(brfe, "AirDrag", 0.07)
    elements.property(brfe, "Weight", 90)
    elements.property(brfe, "Meltable", 1)
    elements.property(brfe, "HighTemperature", 1400)
    elements.property(brfe, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(elements.DEFAULT_PT_IRON, "HighPressure", 18)
    elements.property(elements.DEFAULT_PT_IRON, "HighPressureTransition", elements.TPT_PT_BRFE)
    elements.property(elements.TPT_PT_BRFE, "Update", --*1
    function(i,x,y,s,nt) --1
    if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_IRON then --2
    sim.partProperty(i, "type", elements.TPT_PT_BRFE)
    end --2
    end --1
    ) --*1

    local brtn = elements.allocate("TPT" , "BRTN")
    elements.element(brtn, elements.element(elements.DEFAULT_PT_BRMT))
    elements.property(brtn, "Name" , "TTAD")
    elements.property(brtn, "Description" , "Titanium dust. High melting point.")
    elements.property(brtn, "Color", 0x9e9fb2)
    elements.property(brtn, "Gravity", 0.35)
    elements.property(brtn, "AirDrag", 0.06)
    elements.property(brtn, "Weight", 98)
    elements.property(brtn, "Meltable", 1)
    elements.property(brtn, "HighTemperature", 2000)
    elements.property(brtn, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(elements.TPT_PT_BRTN, "Update", --*1
    function(i,x,y,s,nt) --1
    if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_TTAN then --2
    sim.partProperty(i, "type", elements.TPT_PT_BRTN)
    end --2
    end --1
    ) --*1

    local clay = elements.allocate("TPT" , "CLAY")
    elements.element(clay, elements.element(elements.DEFAULT_PT_BRCK))
    elements.property(clay, "Name" , "CLAY")
    elements.property(clay, "HeatConduct", 2)
    elements.property(clay, "Color", 0x788991)
    elements.property(clay, "Description" , "Clay. Breakable solid with weird heat conductivity.")
    elements.property(clay, "AirLoss", 0.2)
    elements.property(clay, "Hardness", 1)
    elements.property(clay, "HighPressure", 10.14)
    elements.property(clay, "HighPressureTransition", elements.TPT_PT_BRCL)

    local brcl = elements.allocate("TPT" , "BRCL")
    elements.element(brcl, elements.element(elements.DEFAULT_PT_STNE))
    elements.property(brcl, "Name" , "BRCL")
    elements.property(brcl, "Description" , "Broken clay.")
    elements.property(brcl, "Color", 0xa8bbc4)
    elements.property(brcl, "Gravity", 0.05)
    elements.property(brcl, "AirDrag", 0.04)
    elements.property(brcl, "Weight", 60)
    elements.property(brcl, "Meltable", 1)
    elements.property(brcl, "HighTemperature", 873)
    elements.property(brcl, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(elements.TPT_PT_CLAY, "HighPressure", 10)
    elements.property(elements.TPT_PT_CLAY, "HighPressureTransition", elements.TPT_PT_BRCL)
    elements.property(elements.TPT_PT_BRCL, "Update", --*1
    function(i,x,y,s,nt) --1
    if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_CLAY then --2
    sim.partProperty(i, "type", elements.TPT_PT_BRCL)
    end --2
    end --1
    ) --*1

    local ders = elements.allocate("TPT" , "DERS")
    elements.element(ders, elements.element(elements.DEFAULT_PT_BRCK))
    elements.property(ders, "Name" , "DERS")
    elements.property(ders, "HeatConduct", 100)
    elements.property(ders, "Color", 0x848937)
    elements.property(ders, "Description" , "Dest-Resistant solid. Breakable and meltable.")
    elements.property(ders, "AirLoss", 0.2)
    elements.property(ders, "Hardness", 1)
    elements.property(ders, "Meltable", 1)
    elements.property(ders, "Gravity", 0)
    elements.property(ders, "HighPressure", 30.0)
    elements.property(ders, "HighPressureTransition", elements.TPT_PT_DEPD)
    elements.property(ders, "HighTemperature", 2273)
    elements.property(ders, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)

    local depd = elements.allocate("TPT" , "DEPD")
    elements.element(depd, elements.element(elements.DEFAULT_PT_CNCT))
    elements.property(depd, "Name" , "DEPD")
    elements.property(depd, "Description" , "Dest-Resistant powder.")
    elements.property(depd, "Color", 0x646829)
    elements.property(depd, "Gravity", 0.2)
    elements.property(depd, "AirDrag", 0.06)
    elements.property(depd, "Weight", 75)
    elements.property(depd, "Meltable", 1)
    elements.property(depd, "HighTemperature", 2273)
    elements.property(depd, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(elements.TPT_PT_DERS, "HighPressure", 10)
    elements.property(elements.TPT_PT_DERS, "HighPressureTransition", elements.TPT_PT_DEPD)
    elements.property(elements.TPT_PT_DEPD, "Update", --*1
    function(i,x,y,s,nt) --1
    if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_DERS then --2
    sim.partProperty(i, "type", elements.TPT_PT_DEPD)
    end --2
    end --1
    ) --*1

    local flwd = elements.allocate("TPT" , "FLWD")
    elements.element(flwd, elements.element(elements.DEFAULT_PT_WOOD))
    elements.property(flwd, "Name" , "FLWD")
    elements.property(flwd, "HeatConduct", 2)
    elements.property(flwd, "Color", 0xd17300)
    elements.property(flwd, "Description" , "Flashwood. Like flashpowder but solid.")
    elements.property(flwd, "AirLoss", 0.2)
    elements.property(flwd, "Hardness", 1)
    elements.property(flwd, "MenuSection", 5)
    elements.property(flwd, "Flammable", 5000)
    elements.property(flwd, "Meltable", 0)
    elements.property(flwd, "HighPressure", 18)
    elements.property(flwd, "HighPressureTransition", elements.TPT_PT_FPDR)
    elements.property(flwd, "HighTemperature", 573)
    elements.property(flwd, "HighTemperatureTransition", elements.DEFAULT_PT_FIRE)

    local fpdr = elements.allocate("TPT" , "FPDR")
    elements.element(fpdr, elements.element(elements.DEFAULT_PT_SAWD))
    elements.property(fpdr, "Name" , "FPDR")
    elements.property(fpdr, "Description" , "Flashpowder. Burns fast and extremely hot.")
    elements.property(fpdr, "Color", 0xffb356)
    elements.property(fpdr, "Gravity", 0.04)
    elements.property(fpdr, "AirDrag", 0.03)
    elements.property(fpdr, "Weight", 50)
    elements.property(fpdr, "MenuSection", 5)
    elements.property(fpdr, "Flammable", 5000)
    elements.property(fpdr, "HighTemperature", 473)
    elements.property(fpdr, "HighTemperatureTransition", elements.DEFAULT_PT_FIRE)
    elements.property(elements.TPT_PT_FLWD, "HighPressure", 10)
    elements.property(elements.TPT_PT_FLWD, "HighPressureTransition", elements.TPT_PT_FPDR)
    elements.property(elements.TPT_PT_FPDR, "Update", --*1
    function(i,x,y,s,nt) --1
    if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_FLWD then --2
    sim.partProperty(i, "type", elements.TPT_PT_FPDR)
    end --2
    end --1
    ) --*1

    local ings = elements.allocate("TPT", "INGS")
    elements.element(ings, elements.element(elements.DEFAULT_PT_OXYG))
    elements.property(ings, "Name" , "INGS")
    elements.property(ings, "Description", "Insulating Gas. Won't transfer heat. Formed by boiling INLQ.")
    elements.property(ings, "Color", 0xd8daff)
    elements.property(ings, "HeatConduct", 0)
    elements.property(ings, "Diffusion", 1.0)
    elements.property(ings, "Gravity", 0.5)
    elements.property(ings, "Flammable", 0)
    elements.property(ings, "Temperature", 3323.15)
    elements.property(ings, "MenuSection", 6)
    elements.property(elements.TPT_PT_INGS, "LowTemperature", 3273.15)
    elements.property(elements.TPT_PT_INGS, "LowTemperatureTransition", elements.TPT_PT_INLQ)

    local function funcGraphics(i, colr, colg, colb) --*1
    return 1,ren.FIRE_BLEND,30,colr,colg,colb,255,93,91,120
    end --*1
    elements.property(ings, "Graphics", funcGraphics)

    local inlq = elements.allocate("TPT" , "INLQ")
    elements.element(inlq, elements.element(elements.DEFAULT_PT_DSTW))
    elements.property(inlq, "Name" , "INLQ")
    elements.property(inlq, "Description" , "Insulating Liquid. Won't transfer heat. Boils into INGS at 3000C.")
    elements.property(inlq, "Color", 0x99a9c4)
    elements.property(inlq, "Gravity", 0.06)
    elements.property(inlq, "AirDrag", 0.01)
    elements.property(inlq, "HeatConduct", 0)
    elements.property(inlq, "Weight", 25)
    elements.property(inlq, "MenuSection", 7)
    elements.property(inlq, "Flammable", 0)
    elements.property(elements.TPT_PT_INLQ, "HighTemperature", 3273.15)
    elements.property(elements.TPT_PT_INLQ, "HighTemperatureTransition", elements.TPT_PT_INGS)
    elements.property(elements.TPT_PT_INLQ, "Update", --*1
    function(i,x,y,s,nt) --1
    if sim.partProperty(i, "ctype") == elements.TPT_PT_INGS then --2
    sim.partProperty(i, "type", elements.TPT_PT_INLQ)
    end --2
    end --1
    ) --*1

    Edited once by LiquidPlasma. Last: 26th Nov 2018