Element Wrapper

  • cartman300
    11th May 2013 Member 1 Permalink

    Hello, this is a simple element lua wrapper i made,

    it should simplify element creation, it's still WIP.

    Current version is the 1st version and it's made in less than 20 minutes.

     

    http://puu.sh/2QVOC.txt

     

    Element example http://puu.sh/2QVPc.txt

     

    Functions:

    • print(...) - prints crap to console (Optionally appends to log.txt file if ACCESSORIES_LOGGING set to true)
    • printtable(table) - prints table key/value pairs
    • Log(txt) - appends text to log.txt
    • LogRemove() - removes the log.txt file
    • SetBaseElement(ID, BaseElement) - copies BaseElement table to ID element
    • CreateElement(Group, Name, [Optional]Base) - creates element with optional base element, similar to elements.allocate(a,b)
    • GetElement(ID) - wrapper for elements.element(ID)
    • SetElement(ID, Table) - Sets Table to element, similar to elements.element(ID, Table) but including the Update and Graphics functions (if Table contains them)
    • SetPos(Index, X, Y) - sets element with Index to position X,Y
    • SetProp(Index, Property, Value) - wrapper for tpt.set_property(Property, Value, Index)
    • Color(R, G, B) - returns correct hexadecimal color integer

     

     

    Accepting requests.

    Just ask for anything that would simplify stuff even more.

  • mniip
    11th May 2013 Developer 0 Permalink
    print() - do not ever pairs over {...}, it is a bad idea
    EDIT: also, if you didn't notice, new version supports multiargument print, since this commit: https://github.com/FacialTurd/The-Powder-Toy/commit/9f7d45f8fd663a043c5eee26583372d51440d6ff
  • cartman300
    11th May 2013 Member 0 Permalink

    Why would it be a bad idea?

    It's not like somebody would pass on over 2k arguments to print...

  • mniip
    11th May 2013 Developer 0 Permalink
    @cartman300 (View Post)
    print(nil) - doesn't work
  • cartman300
    11th May 2013 Member 0 Permalink

    Removed print thingy, it isn't needed.

    I just added it because for some reason original

    print didn't work when i tested. >.>

    http://puu.sh/2QWV3.txt

     

    EDIT

     

    REVISION 3: http://puu.sh/2QYTP.txt

     

    Added:

    + Element.Sparked(index, x, y) - calls when spark goes trough element

     

    Example element: http://puu.sh/2QZlj.txt