Nuts and bolts of the Substance Pack Editor

  • #1

    Hello fans of Patterns!

    By now I hope you’ve had a chance to read our recent news about where we’re headed with Patterns.  As mentioned there, our focus is to enable you to build whatever experiences you can imagine.  Want to make another zombie cube world survival challenge, a treasure hunt for Platonic solids hidden amongst ancient ruins, or create an adventure of the mysterious plight of a young world shaper awakened on an alien planet?  We want to enable you to create all of these and more, and today’s release is the first step towards that goal.

    I’m excited to be able to unveil the Substance Pack Editor, a tool that allows you to customize the look and feel of your worlds as never before in Patterns.  The release notes and documentation are all you need to know to get up and running with the tool but if you’re interested in what is happening behind the scenes then keep reading.

    First of all, why is it called a Substance Pack and not a Texture Pack?  Well Texture Packs just change the way things look but as you know, Patterns substances have a visual representation and properties that affect gameplay.  The Substance Pack Editor allows you to edit both.  You can make your own quicksand or fashion a new type of bouncy moon rock that crumbles underfoot.  All the properties you’ve seen in the cosmos are now yours to control.

    The substance packs that you create are stored near your world save files.  On Windows, the path to a substance pack called “Ruination” will be something similar to this, depending on your username:

    C:\Users\Leslie\AppData\LocalLow\LindenLab\Patterns\UGC\SubstancePacks\Ruination

    If you poke around a bit in a directory for one of these substance packs that you have created, you will notice a few PNG files, a “settings.lua” file, a “sourcePaths.txt” file and large number of subdirectories with the textures for each substance within it.  The bulk of these files are used as input for the Substance Pack Editor but not by the game.  The only critical files for the game are the output files from the Substance Pack Editor which include the texture atlas files “main.png”, “normal.png”, “combo.png”, “metal.png” and the “settings.lua” file.  The appearance of each substance is completely determined by these texture files and the behavior of the substances in game comes from the “settings.lua” file.  So go ahead and open it up in a text editor!

    The bulk of the script calls in the “settings.lua” file match up directly to the dials you have seen in the Substance Pack Editor.  At the very top of the file there’s a little bit of boiler plate code to give us a shorthand way to access the Patterns.Substance table where all of the substance modification functions live:

    subs = Patterns.Substance

    And then the rest of the script uses that shorthand directly:

    -- Settings for the 'Ruin Ten' substance
    subs.SetName(2, "Ruin Ten")
    subs.SetCrumble(2, 0)
    subs.SetDurability(2, 2)
    subs.SetLift(2, 0)
    subs.SetWeight(2, 10)
    subs.SetBehavior(2, 0)
    subs.SetLightIntensity(2, 0)
    subs.SetLightColor(2, "#FFFFFF")
    subs.SetDamageToPlayer(2, 0)
    subs.SetFootprintColor(2, "#AAAAAA")
    subs.SetFootprintTime(2, 5.925926)

    The first thing to notice is that the functions are written using CamelCase, our chosen convention for all of the Lua scripting functions we’ll be bringing to you.

    Then you’ll notice that every function in this particular example is called with the number “2” as the first argument.  That is the reference to the index of the substance we’re overriding.  So in this example, substance 2 is going to have its name changed to “Ruin Ten” and have its other properties modified as well.

    Each line of script defines a single property, which are in order:  name, crumble, durability, lift, weight, behavior, light intensity, light color, damage to player and footprint color and time.  This might seem like overkill given that all you wanted was to make the block solid green but this allows you to change how the avatar interacts with the substance.  For example, changing the SetCrumble function parameter from 0 to 1 or 2 will cause it to crumble when the avatar walks on it.  Or reducing the SetDurability parameter would allow the avatar to mine the substance more quickly, or adjusting the SetLift parameter will cause it to float in the air like the nefarious “wasp wing” substance from the default substances.  Go ahead and experiment with the settings and see what you come up with.  Just be warned that modifying the file while it is also in use by the Substance Pack Editor may cause some changes to be lost.

    These functions and more like it will be documented more thoroughly on the wiki in the new year as we roll out and expand the scripting interface for Patterns.

    There are a few settings that didn’t quite make it into this release of the Substance Pack Editor but those will come soon, along with several knobs to adjust lighting and screen effects to give you the power to fully customize the look and feel of your creations.

    Feel free to contact us if you have further suggestions on how to increase your creative potential in Patterns.  And please share your creations with us through the cosmos!

    Leslie Von Pischke, Patterns lead engineer @ Linden Lab

  • To post a comment, please or register a new account.
Posts Quoted:
Reply
Clear All Quotes