I'm trying to script my first element, and for the most part it's going well. However, I would like to make it convert certain elements to other elements on contact. Here's the relevant part of my code, where I tried to make any WATR particle under it change to EXOT. Unfortunately, it's not working, and it might have something to do with the fact that I have no idea what the "s" and "n" variables do, apart from that they stand for "surround_space" and "nt" and that a lot of scrips use them. Any help will be much appreciated!
<code>
function magic(i,s,n,x,y)
if tpt.get_property("type",i,x,y+1) == tpt.el.watr.id then
tpt.set_property("type","exot",x,y+1)
end
end
tpt.element_func(magic,tpt.el.bran.id)
</code>
EDIT: Also, why don't my <code> tags seem to work?
I think you should take out the "i" in tpt.get_property.
tpt.el.bran.name="MGCK"
tpt.el.bran.description="Turns water into exot."
tpt.el.bran.menusection=4
tpt.el.bran.enabled=1
tpt.el.bran.heat=293.15
function magic(i,x,y,s,n)
if tpt.get_property("type",x,y+1) == tpt.el.watr.id then
tpt.set_property("type",tpt.el.exot.id,x,y+1)
end
end
tpt.element_func(magic,tpt.el.bran.id)
it is (i,x,y,s,n). you need the right order
I also added some other stuff that helps...
good luck!
(btw: you need to use element search to find it.. sorry)
So, my element's working quite well (thanks, asdf123), but I created a few other little projects and I want them all to autorun. However, I don't want to remove any default elements in the process, so I'm wondering if it's possible to create multiple modded elements out of BRAN at the same time, or to do something else to the same end. Is it possible? If so, how?
Thanks in advance for any help!
local myNewElement = elements.allocate("wiki", "expl")
elements.element(elements.WIKI_PT_EXPL, elements.element(elements.DEFAULT_PT_WATR))
elements.property(elements.WIKI_PT_EXPL, "Name", "EXPL")
elements.property(elements.WIKI_PT_EXPL, "Description", "This is an example element from the Wiki")
I'm trying what you said, Jacob1, but I'm not sure how the syntax is supposed to work with that system, because I typed in
elements.property(elements.LUA_PT_GLUE,"Menusection",6)
and it said Menusection was an invalid property. How do I go about adding element properties?
EDIT: Nevermind, I fixed it. It just had to be "MenuSection" instead of "Menusection."