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.
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.
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
It's accessible from C++ only?
TPT_PL:
No it isn't. [...]
No? no what?
[...]Just use something likeelem.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!
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"
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)