Cr15py's Standard API Extensions

  • Cr15py
    31st Jul 2011 Member 0 Permalink
    Intro:
    I have extended the standard Powder Toy API with the following functions:
    -tpt.clear_screen(): deletes everything on screen
    -tpt.set_all(variable, value): Sets the variable of everything on screen to value. E.g. to turn everything to metal type tpt.set_all("type", "metl")
    -tpt.get_info(x,y) or tpt.get_info(index). Returns an table containing all information that I could gather about the particle. Information can be accessed by entering the variable's name. e.g. info = tpt.get_info(100, 100)tpt.log(info["type"]). That will return the type of the particle at x:100, y:100.
    -tpt.get_time(): returns the time.
    -tpt.get_os(): Currently only detects whether user is on a *nix system or a Windows system. Will return "*nix" or "Windows" accordingly.
    -tpt.dump_table(table): Returns the contents of the given table in a string format
    -tpt.id_to_string(id): allows a user to convert the id of an element(returned by tpt.get_property("type",...)) to the element name(so it can be used with set_property, etc.)
    -tpt.set_info(info, [index]/[x,y]): Set multiple properties at once based off a table of properties.
    -tpt.create_empty_table(): Returns an empty table of properties to be used with tpt.set_info()
    -tpt.lock_variable(variable, value, index): Prevents variable from changing, keeps variable at the value specified in value. X, Y, VX, and VY may be buggy.


    Instructions:
    NOTE: If you have my modloader, just put the file name in the mods.txt file and place the file in the /lua folder. Also note that you do not have to name the file macros.lua, it's simply for continuity in this tutorial.
    1) Download the file from here. Name the file "macros.lua".
    2) Open Powder Toy.
    3) Open console(press "~" or "`").
    4) Type dofile("macros.lua")
    5) Use these useful functions! n_n

    To Developers:
    To use this in your scripts, simply put the file in the same directory, and in your script, before you use any of my functions, run dofile("macros.lua").
  • BlueAmulet
    31st Jul 2011 Member 0 Permalink

    Deleted

    Edited once by BlueAmulet. Last: 12th Apr 2024
  • Cr15py
    31st Jul 2011 Member 0 Permalink
    They aren't unneeded... they are just some additions I made, you douchebag. Many of the actual API functions are unneeded, but I don't see you bitching about them. How in hell can you say that converting an element id to string is useless? Or that getting all the variables of a particle neatly arranged into an array wouldn't make developing faster? If you don't like them, don't use them. I'll be adding more functions soon that will be more useful, most of this is really just testing and demonstrating(to myself and others) what you can do with Lua.
  • BlueAmulet
    31st Jul 2011 Member 0 Permalink

    Deleted

    Edited once by BlueAmulet. Last: 12th Apr 2024
  • Pilihp64
    31st Jul 2011 Developer 0 Permalink
    The huge list of particle names is not needed, the create/property commands should also work with numbers, unless you just want the string to display to users from the Lua side, but it isn't needed to set things.

    The rest are just much simpler wrappers for the other methods, which some people may find easier to understand.
  • Cr15py
    31st Jul 2011 Member 0 Permalink
    @gamax92 (View Post)
    The language is for you attacking me about this. A little criticism is fine. Telling me this is unneeded? Trolling.
  • TheWiseEyes
    31st Jul 2011 Banned 0 Permalink
    This post is hidden because the user is banned
  • Cr15py
    31st Jul 2011 Member 0 Permalink
    @TheWiseEyes (View Post)
    Feel free, put everything you want there. I was thinking of the same idea(a repository for scripts). I didn't know you were making one but if I can help in any way I will donate my extensive knowledge of my many programming languages to helping out.
  • TheWiseEyes
    31st Jul 2011 Banned 0 Permalink
    This post is hidden because the user is banned
  • Cr15py
    31st Jul 2011 Member 0 Permalink
    BUMP. Changes have been made.
    Edited Post.
    Added tpt.set_info(), tpt.create_empty_table(), and tpt.lock_variable()
    Updates download link.