Using old api

  • bugzeeolboy
    3rd Nov 2012 Member 0 Permalink

    How do I use the old API with new elements that I create, or how do I create elements using the old API and not use BRAN to overwrite my new element?

     

    What I don't want:

    <code>

    tpt.el.bran.name="ZOMG"

    </code>

     

    What I do want:

    <code>

    newelement = elements.allocate("bugz", "zomg")

    tpt.el.zomg.name="ZOMG"

    --or something like that, so I can use a new element and not overwrite bran.

    </code>

     

    EDIT: Sorry, I am making a lot of posts. I just need a lot of lua help.

     

    EDIT AGAIN: Hello? Anyone? Helloooo?

  • Simon
    3rd Nov 2012 Administrator 1 Permalink
    "tpt.el.zomg.name="ZOMG"" No longer works with the new API, you should use:

    --Create a new element
    local newelement = elements.allocate("bugz", "zomg")

    --Set name and other properties of new element
    elem.property(newelement, "Name", "ZOMG")
    --or
    elem.property(elem.BUGZ_PT_ZOMG, "Name", "ZOMG")


    See https://powdertoy.co.uk/Wiki/W/Lua_API:Elements.html for more
  • bugzeeolboy
    3rd Nov 2012 Member 0 Permalink

    @Simon (View Post)

     is there any possible way to actually create elements without overwriting bran with the old API?

  • Simon
    3rd Nov 2012 Administrator 0 Permalink
    No, there isn't.
  • nucular
    19th Dec 2012 Member 0 Permalink

    @simon im sad there isnt :(

    so many useful mod-elements with that i want to build something with, all together...

  • boxmein
    19th Dec 2012 Former Staff 0 Permalink
    @nucular (View Post)
    Use the new API, it's fairly straight forward...
    From
    tpt.el.awesome.name= "Value"
    to
    elem.property(elem.NS_PT_AWESOME, "Name", "Value")
    ?