Jump to content
catty-cb

Using Custom Resource Types and Limits in Banished

2 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

This example shows how to use custom resource types and limits. Previous versions of the game were limited to the built in resource types. Food, Iron, Wood, etc. There are 10 Custom resource limits that can be used however modders see fit. Once the mod is loaded, the status bar, resource limit window, and the town hall production and graphs will show an additional set of resources. Currently these are simple called Custom0, Custom1 ... Custom9. It's up to a modder to change the string tables to define what each custom resource is. To build this mod, run

bin\x64\Tools-x64.exe /build limitResources.rsc /pathres ../example/limitresource /pathdat ../example/limitresource/bin

You can build the mod into a package like so:

bin\x64\Tools-x64.exe /mod Package.rsc:limitResource /pathres ../example/limitresource /pathdat ../example/limitresource/bin

To test the mod by itself, you can run the game forcing it to only use packages.

bin\x64\Application-x64-profile.exe /onlypkg

There are 10 custom resources available. This mod doesn't actually modify any buildings or resources to use the custom types. Here's an overview on how you would change the Apiary to use a custom resource type and limit.

  1. In the building example, open Template/Apiary.rsc.
  2. Modify the ConsumeProduceDescription to use a custom resource type. It currently is food. Change
    ResourceLimit _resourceLimit = Food;
    to
    ResourceLimit _resourceLimit = Custom5;
  3. Modify the ResourceLimitUIConfig to use a custom resource type. Again change
    ResourceLimit _resourceLimit = Food;
    to
    ResourceLimit _resourceLimit = Custom5; // this could be Custom[0..9]
  4. Modify the tooltip UI elements to change the text on the tooltip
    String _toolTipText = "FoodLimitTip";
    becomes
    String _toolTipText = "Custom5LimitTip";
  5. Modify the text UI element to change the text on the dialog
    String _text = "FoodLimit";
    becomes
    String _text = "Custom5Limit";
  6. Note that in this mod Template/Citizen.rsc and Template/StorageBarn.rsc have been modified to be able to store certain resource types. For your own storage areas you'll have to modify them as needed.
    RawMaterialFlags _storageFlags = Edible | Fuel | Tool | Wood | Stone | Iron | Health | Clothing | Textile | Alcohol | 
    		    Custom0 | Custom1 | Custom2 | Custom3 | Custom4 | Custom5 | Custom6 | Custom7 | Custom8 | Custom9;
  7. If desired change all the string table entries for Custom5 to match whatever you want your resource type and limit to be called. There are several places to change in the StringTable.rsc. Their names are
    • Custom5Limit
    • Custom5LimitShort
    • Custom5LimitTip
    • Custom5Tip
    • Type18 (this string entry is the named use when displayed as a graph in the town hall)
  8. You'll want to eventually modify the user interfaces to only display the limits and graphs that you want. Generally look for the word 'custom' in these resource files:
    • Dialog/StatusBar.rsc contains the custom items listed on the Status Bar in game. Any custom field can be ommited if not all 10 custom resource limits are used.
    • Dialog/TownHall.rsc contains fields where resource limits are placed used on the Production Tab in the town hall. It also modifies the production tab to have a scroll bar to keep the town hall window small. Some additional UI resizing may be needed.
    • Template/TownHall.rsc contains the UI config that adds the resource limits to the TownHall dialog.
    • Template/UtilityLimits.rsc contains the UI config that add the resource limits to the limits dialog.
    • Dialog/StringTable.rsc contains strings used to name the custom resources. To remove custom resources that are unused from the graphs, simply leave the strings blank, or truncate the list.
    • Template/TradingPost.rsc contains changes to add custom resource types to the auto purchase UI list. Note that if you change this list you need to update the number of entries in the table in the UI. This is located in Dialog/Trade.rsc. (TableDescription tablePurchase needs the _height value to match the number of entries)
    Note that if two mods are loaded that both use a custom resource types that clash, behavior is undefined - resources you expect to be grouped with a certain type may have the wrong name and logically unrelated types will end up with the same resource type and limit.

More than 3 resource requirements for a building

This example shows how to use more than 3 resource items when constructing a building. Previous versions of the game were limited to 3, and if more were used a crash was seen. Once the mod is loaded, the basic wooden house requires six items for construction, Wood, Stone, Iron, Tools, Firewood, and Coal To build this mod, run

bin\x64\Tools-x64.exe /build buildRequirement.rsc /pathres ../example/buildrequirement /pathdat ../example/buildrequirement/bin

You can build the mod into a package like so:

bin\x64\Tools-x64.exe /mod Package.rsc:buildRequirement /pathres ../example/buildrequirement /pathdat ../example/buildrequirement/bin

To test the mod by itself, you can run the game forcing it to only use packages.

bin\x64\Application-x64-profile.exe /onlypkg

Here's a basic list of changes required to use more resources when constructing buildings

  1. In ToolTipToolBar.rsc, change the layout to have as many labelBuildX as are required (i.e. labelBuild3, labelBuild4, ...)
  2. In CreateBar.rsc, change make a similar change adding more labelBuildX as are required
  3. In Build.rsc change the storageTable to have as many entries as are required, plus an additional one thats used for the amount of work required.
  4. In whichever building you want, change the build section to have more items, See WoodHouse.rsc:build.
  5. Optional: If desired, per building, the UI can be changed to match the number of required resources. You'd have to change the UIDescription to point at a dialog with the correct number of items in the storage table, instead of the default "Dialog/Build.rsc:build"

preview.jpg

  • Like 1

Share this post


Link to post
Share on other sites

×

Thank You for the Continued Support!

Simtropolis depends on donations to fund site maintenance costs.
Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

Make a Donation, Get a Gift!

Expand your city with the best from the Simtropolis Exchange.
Make a Donation and get one or all three discs today!

STEX Collections

By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

Each donation helps keep Simtropolis online, open and free!

Thank you for reading and enjoy the site!

More About STEX Collections