Structure Pools

From wiki
Revision as of 07:21, 2 February 2018 by DeamonHunter (Talk | contribs) (Initial Commit.)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In Staxel, *.structurepool files are used to specify a collection of Structure Templates which are to be randomly pulled from. This is meant to allow you to use multiple different buildings together. are to be played together. These files also contain a type property to describe what type of dialogues are collected.

Creating New Dialogue Pools

Structure Pools is Staxel's main way with interacting with Structures. These files allow the game to have differing weights for which building can spawn and where.

Before you start this tutorial, be sure to head through Modding#Getting Started with Staxel Modding.


The first step would be to go through Structures#Creating a *.structuretemplate file if you don't already have a structure to implement. After that you are ready to go on to creating the pool.


Creating the *.structurepool file

Adding the Structure Pool via Asset Manager

Follow Modding#Using the AssetManager to Create Mods to open up the Asset Manager.

With the Asset Manager open, head to View → Tiles and Objects → Structure Assets. When the new window is open, head to Asset → Add → New Asset and the following window will show up.

Asset Manager - New Asset.png

First click on the button Asset Path and navigate upwards to the /content/ folder. Once there, open the /mods/ folder and create a new folder. Name this new folder to what you want the mod to be called and then open this new folder. When you open this folder give the asset a name, then click on the drop down and select Structure Pool Asset. Then click save, give the item a code then click OK.

After the asset is created, it will have been automatically selected. With that it is now time to tell the game what you want to do with this Villager Design. The following set of steps highlight the important properties, however you can mess with any property.

  1. Click on Options. Click on the [...].
  2. Click on Add.
  3. Click on Template. Click the Dropdown and find your structure in that list.

Keep repeating these steps for all the structures you want in this pool. Once this is done, you can

With that, hit Crtl+S to save the file. And then go to File → All Assets → Build and Validate Assets. If this succeeds, then HURRAY! you have a new tile in the game. If it fails, try and read the error to see what you have done wrong.


Now you just need to add it to something. In most cases, these files are used by worldgen. Which is not possible to change at this point without editing Staxel's files.


Adding the Dialogue via Text Files

Follow Modding#Using a Text Editor to Create Mods in order to be properly set up for this step.


Creating this file is very simple as it only two properties. The full file will looks like;

{
  "code": "staxel.structurePool.GeneralStore",
  "options": [
    {
      "chance": 1.0,
      "template": "staxel.structure.village.GeneralStore"
    },
    {
      "chance": 1.0,
      "template": "staxel.structure.village.GeneralStore2"
    }
  ]
}

With the file being this short, there is no need for pictures. Here is the explanation of the four properties.

  • "code": A unique String that would be used to identify this object from others. For example this is like "staxel.item.crafting.BakingPowder" or "staxel.tile.grass". You will most commonly want to use you use the path to the Accessory Model but replace / with ., as this will ensure your design will have a different code to all other designs.
  • "options": A List of Blobs that contains all of the structures in this structure pool. Inside of these blobs are two more properties.
  • * "chance": A Float which sets the relative chance of getting this specific structure. The actual chance is chance/TotalChance Where total chance is the addition of all chances.
  • * "code": A String which contains the Code of a Structure Template. This will be the structure that will be places.


After you have done editing the file, head to gamedata/bin/ folder, and start up Staxel.ContentBuilder.exe. When this has started up, click "Tag dialogue and generate language file". This will open up a file browser. Go to your newly created file (The .dialogue file from the first section.) and select that. After that, click Validate Resources<tt> and wait until the progress bar has done. And with that you should have a working item. If you are confused then go to the #Modding channel on Discord and ask there.


Now you just need to add it to something. In most cases, these files are used by worldgen. Which is not possible to change at this point without editing Staxel's files.


Config Options

"code"

Valid options (String): A unique string which structure pool this object is.

Default Value: No default value is specified. Always need to provide your own.


A string containing the unique identifier of the structure pool.


"options"

This contains all of the possible structure files to spawn when choosing this structure. This allows you to have multiple different structures that all serve the same purpose.

"options": [
  {
    "chance": 1.0,
    "template": "staxel.structure.village.GeneralStore"
  }
]

Each entry is mainly just a weighted chance and a Structure Template.


"chance"

Valid options (Float): A positive decimal number

Default Value: No default value is specified. Always need to provide your own.


The relative chance of getting this specific structure. The actual chance is chance/TotalChance Where total chance is the addition of all chances.


"template"

Valid options (String): A strings which point to a Structure Template code.

Default Value: No default value is specified. Always need to provide your own.


This is the specific Structure that will be spawned.