Script help

  • Dinnersauce
    4th Oct 2012 Member 0 Permalink

    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?

  • Jallibad
    4th Oct 2012 Member 0 Permalink

    @Dinnersauce (View Post)

     I think you should take out the "i" in tpt.get_property.

  • billion57
    4th Oct 2012 Member 0 Permalink

    If you keep the "i", it would ask for an element to be converted into another element. Change the 2nd i to "WATR", and remove the first one.

     

  • mniip
    4th Oct 2012 Developer 0 Permalink
    @Dinnersauce (View Post)
    disable WYSIWYG for code tags,

    do what @Jallibad (View Post) said
  • asdf123
    4th Oct 2012 Member 0 Permalink

    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)

  • Dinnersauce
    5th Oct 2012 Member 0 Permalink

    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!

  • billion57
    5th Oct 2012 Member 0 Permalink

    You can make one autorun by naming it autorun.lua, you could try using the dofile(file.lua) command to run the rest.

  • jacob1
    5th Oct 2012 Developer 0 Permalink
    With tpt++, it's possible to create lots of extra elements, I think it has over 100 free slots.

    See this wiki page. I can't remember right now how exactly to use it though, it might be something completely new.

    Edit: It comes with this example:
    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")


    This way is a lot longer, but it allows multiple slots. And "EXPL" is taken by my mod...
  • Dinnersauce
    5th Oct 2012 Member 0 Permalink

    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."

  • jacob1
    5th Oct 2012 Developer 0 Permalink
    @Dinnersauce (View Post)
    ok, i'll add the different properties to the wiki when I have time, they are slightly different then tpt and case sensitive. I don't know why they are missing. At least you understand it though, I didn't when I first saw it.