Help making "plastic" element

  • edr-01
    30th Aug 2016 Member 0 Permalink

    Hello, I'm thinking about doing a new (lua) element: Plastic. I'll explain a bit about my idea:

     

    I want a "plastic" that blocks air pressure and electricity and it's meltable. I wrote some code for the element, the element insulates electricty and melts, but doesn't block pressure. Here's the code:

     

     local plst = elements.allocate("MOD", "PLST")
     elements.element(elements.MOD_PT_PLST, elements.element(elements.DEFAULT_PT_WAX))
     elements.property(elements.MOD_PT_PLST, "Name", "PLST")
     elements.property(elements.MOD_PT_PLST, "Description", "Plastic, blocks electricity and air pressure. Lower melting point than most materials.")
     elements.property(elements.MOD_PT_PLST, "Colour", 0x768d96)
     elements.property(elements.MOD_PT_PLST, "Loss", 0)
     elements.property(elements.MOD_PT_PLST, "Weight", 100)
     elements.property(elements.MOD_PT_PLST, "Meltable", 1)
     elements.property(elements.MOD_PT_PLST, "Flammable", 0)
     elements.property(elements.MOD_PT_PLST, "Hardness", 65)
     elements.property(elements.MOD_PT_PLST, "HighTemperature", 695.15)
     elements.property(elements.MOD_PT_PLST, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
     elements.property(elements.MOD_PT_PLST, "Properties", TYPE_SOLID)
     elements.property(elements.MOD_PT_PLST, "MenuSection", SC_SOLIDS)

     

    -- End of the code

     

    By some reason, have a orange hue instead the bluish one, I don't know how to solve it. Solved. I need (or I should say "I want") help wiith the pressure block. Thanks

     

    P.S: My english isn't very good, I have grammar errors, sorry

    P.P.S: Thanks guys! Everything was tested but didn't work. I'll let this thread die. When the element is ready I'll create another thread.

    Edited 3 times by edr-01. Last: 18th Sep 2016
  • LBPHacker
    30th Aug 2016 Developer 0 Permalink

    It's bluish on my end. Given the colour code, it should be bluish as well.

     

    The problem with TTAN is that it accesses sim->air->bmap_blockair in its Update function, which is not accessible from Lua.

     

    A tip: since elem.allocate already gave you the ID of your new element, you could just use that instead of elem.MOD_PT_PLST.

  • Ben_Ger
    2nd Sep 2016 Member 0 Permalink

    You should consider programming it to also be flamable after melting, just a suggestion.

  • edr-01
    10th Sep 2016 Member 0 Permalink

    @Ben_Ger (View Post)

     Yes, it's possible make it flamable:

     

    code:

     

     local plst = elements.allocate("MOD", "PLST")
     elements.element(elements.MOD_PT_PLST, elements.element(elements.DEFAULT_PT_WAX))
     elements.property(elements.MOD_PT_PLST, "Name", "PLST")
     elements.property(elements.MOD_PT_PLST, "Description", "Plastic, blocks electricity and air pressure. Lower melting point than most materials.")
     elements.property(elements.MOD_PT_PLST, "Colour", 0x768d96)
     elements.property(elements.MOD_PT_PLST, "Loss", 0)
     elements.property(elements.MOD_PT_PLST, "Weight", 100)
     elements.property(elements.MOD_PT_PLST, "Meltable", 1)
     elements.property(elements.MOD_PT_PLST, "Flammable", 1)
     elements.property(elements.MOD_PT_PLST, "Hardness", 65)
     elements.property(elements.MOD_PT_PLST, "HighTemperature", 695.15)
     elements.property(elements.MOD_PT_PLST, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
     elements.property(elements.MOD_PT_PLST, "Properties", TYPE_SOLID)
     elements.property(elements.MOD_PT_PLST, "MenuSection", SC_SOLIDS)

     

    -- End of the code

     

    @LBPHacker (View Post)

    It's accessible from C++ only?

    Edited once by edr-01. Last: 13th Sep 2016
  • TPT_PL
    10th Sep 2016 Member 0 Permalink
    No it isn't. Just use something like elem.property(plst, "Name", "LOLZ")
  • edr-01
    12th Sep 2016 Member 0 Permalink

     

    TPT_PL:

    No it isn't. [...]
    No? no what?
     
    [...]Just use something like elem.property(plst, "Name", "LOLZ")

     In order to make what? I finally understood what do you mean. I can use (plst, "Name", "PLST") instead (elements.MOD_PT_PLST, "Name", "PLST"). Thanks for the advice!

    Edited 3 times by edr-01. Last: 15th Sep 2016
  • edr-01
    15th Sep 2016 Member 0 Permalink

    Bump. I found a way to make the plastic work, everything (except HighTemp transition) works, but disables the TTAN element :(

    Here's the code:

     

    tpt.el.ttan.name="PLAS"
    tpt.el.ttan.colour=0x768d96
    tpt.el.ttan.weight=100
    tpt.el.ttan.falldown=0
    tpt.el.ttan.hardness=65
    tpt.el.ttan.description="Plastic, blocks electricity and air pressure. Lower melting point than most materials"

  • TPT_PL
    15th Sep 2016 Member 0 Permalink
    I think you can use something like that in update func:
    sim.pressure(x/4, y/4, 0)
    Not exactly air blocking, but might work. :P
  • edr-01
    15th Sep 2016 Member 0 Permalink

    Looks that I'm doing something wrong: The update func doesn't do anything. I'm feeling like a noob:

     

    local plst = elements.allocate("MOD", "PLST")
    elements.element(elements.MOD_PT_PLST, elements.element(elements.DEFAULT_PT_WAX))
    elements.property(elements.MOD_PT_PLST, "Name", "PLST")
    elements.property(elements.MOD_PT_PLST, "Description", "Plastic, blocks electricity and air pressure . Lower melting point than most materials.")
    elements.property(elements.MOD_PT_PLST, "Colour", 0x768d96)
    elements.property(elements.MOD_PT_PLST, "Loss", 0)
    elements.property(elements.MOD_PT_PLST, "Weight", 100)
    elements.property(elements.MOD_PT_PLST, "Meltable", 1)
    elements.property(elements.MOD_PT_PLST, "Flammable", 0)
    elements.property(elements.MOD_PT_PLST, "Hardness", 65)
    elements.property(elements.MOD_PT_PLST, "HighTemperature", 973.15)
    elements.property(elements.MOD_PT_PLST, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(elements.MOD_PT_PLST, "Properties", TYPE_SOLID)
    elements.property(elements.MOD_PT_PLST, "MenuSection", SC_SOLIDS)
    function PLST_Update(i, x, y, ss, nt)
    -- i: particle index
    -- x, y: particle x, y coords
    sim.pressure(x/4, y/4, 0)
    end
    elements.property(plst, "Update", PLST_Update)

     

    Edited 3 times by edr-01. Last: 15th Sep 2016
  • TPT_PL
    15th Sep 2016 Member 0 Permalink
    Dunno. Maybe try
    sim.pressure((x-1)/4, (y-1)/4, 0, 3, 3)
    PS: I support elem.property(plst, "Update", PLST) rather than tpt.element_func() (or wasnt that tpt.elem_func()?)