Timberborn

Timberborn

Not enough ratings
[For Modders] Moddable Prefab (U7 Only ✅)
   
Award
Favorite
Favorited
Unfavorite
Mod
File Size
Posted
Updated
69.552 KB
19 Mar @ 10:43am
2 Apr @ 11:26am
4 Change Notes ( view )

Subscribe to download
[For Modders] Moddable Prefab (U7 Only ✅)

In 1 collection by Luke ✞ Jesus Saves ✞
U7 Compatible Mods (My mods only)
75 items
Description
With this mod, modders can make a lot more with 100% code-less mods (using JSONs). Previously they cannot modify values put inside a Prefab (including buildings' Science cost, Material , Power etc.) without using code. Now they can do it with JSONs.

Note to players: This mod does nothing by itself. It is for modders to create mods and you probably subscribe to this mod as a dependency for other mods to work.

Simply create blueprints files and that's it. It can be Blueprints\PrefabModder\AddLumbermill.json, the name and path does not matter as long as it is in the Blueprints folder. Below are some examples of what you can do with this mod.

If you need any help, please ping me on the Timberborn's Official Discord server. You can also check out my Modding Guide[datvm.github.io] for more information on where to find out about the names and values (right now it's still a WIP but the first 2 parts are already there). You can also check out Berry Bie and Timbits & Timbots, they are JSON-only mods (no C# code or assets).

===

Change logs

v7.1.2: Should work with April 02 update now, dependent mods don't need to do anything.

v7.1.1:
- Fixed Prefab being modified twice again when the game is loaded the 2nd time onwards. This mostly affected "AppendArray" specs.
- Added a Distinct() call for all "AppendArray" specs so string[] or array of structs should only contain unique values when multiple mods append the same values.

v7.1.0:
- Added PrefabAddComponentSpec support for adding components to a prefab (GameObject).
- Allow single quote ' in the NewValue property instead of double quote only. They are converted into double quote under the hood. Use \' if you want to keep it as '.
- Allow underscore _ as ValuePath to set the current Component value.

Remove all sciences

Set all BuildingSpec _scienceCost to 0, which means all buildings are unlocked from start:

{ "PrefabModderSpec": { "ComponentType": "Timberborn.Buildings.BuildingSpec", // BuildingSpec is valid but a full name is better "ValuePath": "_scienceCost", "NewValue": "0" } }

Change a specific building:

Now it's not very good to apply a change to all buildings. Let's change only the Dam by... adding 1 Science cost:

{ "PrefabModderSpec": { "ComponentType": "Timberborn.Buildings.BuildingSpec", // BuildingSpec is valid but a full name is better "PrefabNames": [ "Dam.Folktails", "Dam.IronTeeth" ], // Optional in case multiple things may match the ComponentType "ValuePath": "_scienceCost", "NewValue": "1", // It must be a string that is a JSON "AppendArray": true // We will use this later but here it is ignored because the value is not an array } }

Change building material cost:

Say we want to make Dam cheaper by adding 1 Plank to it:

{ "PrefabModderSpec": { "ComponentType": "Timberborn.Buildings.BuildingSpec", "PrefabNames": [ "Dam.Folktails", "Dam.IronTeeth" ], "ValuePath": "_buildingCost", "NewValue": "[{\"_goodId\": \"Plank\", \"_amount\": 1}]", "AppendArray": true // Add to the array instead of replacing it } }

Now that's a little too much, now it costs 20 Logs and 1 Plank. Let's change the cost completely to 10 Logs and 1 Plank:

{ "PrefabModderSpec": { "ComponentType": "Timberborn.Buildings.BuildingSpec", "PrefabNames": [ "Dam.Folktails", "Dam.IronTeeth" ], "ValuePath": "_buildingCost", "NewValue": "[{\"_goodId\": \"Log\", \"_amount\": 10}, {\"_goodId\": \"Plank\", \"_amount\": 1}]" } }

Note: Removing a certain value is not supported. Accessing a specific index in an array is not supported. You can only change the whole array.

Add a recipe to a building:

Well you could have done that with Moddable and Unlockable Recipe but with this mod, you can also add/remove recipes to buildings and change other stuff as well, so it's up to your choice.

The below code add Treated Plank recipe to Lumber Mill. You can also create your own recipe and add it to the building.

{ "PrefabModderSpec": { "ComponentType": "Timberborn.Workshops.ManufactorySpec", "PrefabNames": [ "LumberMill.Folktails", "LumberMill.IronTeeth" ], "ValuePath": "_productionRecipeIds", "NewValue": "[\"TreatedPlank\"]", "AppendArray": true // Add a new recipe } }

Add range to a building

From v7.1.0 you can now add new components into an existing prefab like a building using PrefabAddComponentSpec. The below code add ContinuousEffectBuildingSpec and RangedEffectBuildingSpec into the Hedge building:

{ "PrefabAddComponentSpec": { "ComponentType": "Timberborn.Buildings.BuildingSpec", "PrefabNames": [ "Hedge.Folktails", "Hedge.IronTeeth" ], "AddComponents": [ "Timberborn.RangedEffectSystem.ContinuousEffectBuildingSpec", "Timberborn.RangedEffectSystem.RangedEffectBuildingSpec" ] } }

You can then also add values to those components:

{ "PrefabModderSpec": { "ComponentType": "Timberborn.RangedEffectSystem.ContinuousEffectBuildingSpec", "PrefabNames": [ "Hedge.Folktails", "Hedge.IronTeeth" ], "ValuePath": "_", "NewValue": "{'_effectSpecs':[{'_needId':'Hedge','_pointsPerHour':1,'_satisfyToMaxValue':true}]}" } } { "PrefabModderSpec": { "ComponentType": "Timberborn.RangedEffectSystem.RangedEffectBuildingSpec", "PrefabNames": [ "Hedge.Folktails", "Hedge.IronTeeth" ], "ValuePath": "_", "NewValue": "{'_effectRadius':3}" } }

===
Source code is available at: https://github.com/datvm/TimberbornMods
Popular Discussions View All (1)
5
14 Jul @ 11:38pm
Specify prefab
Luke ✞ Jesus Saves ✞
9 Comments
Luke ✞ Jesus Saves ✞  [author] 14 Jul @ 10:06pm 
I don't think Steam comment is good for this discussion so I created a discussion here: https://steamhost.cn/steamcommunity_com/workshop/filedetails/discussion/3447837683/582769417678692070/
Luke ✞ Jesus Saves ✞  [author] 14 Jul @ 1:40pm 
Oh yeah sorry I wasn't able to write guide for this one yet 😅 it wasn't high on the priority list because I have plenty of example on this one. Do you have a specific problem you need help immediately with? You can ask me on Discord, ping me @theapologist316 on #mod-creators channel should be good.
crashfly 13 Jul @ 3:46pm 
your modding guide has a missing link on #4 - using json and moddable prefabs.

i am hoping to use this mod to tweak the defaults of another mod.
Panchito Mágico 30 Jun @ 4:02am 
Solved!
I am searching, reading and fixing it by myself! Do not worry and thanks! :)
Luke ✞ Jesus Saves ✞  [author] 30 Jun @ 3:51am 
Hi, will need a longer log than that to find out which mod or what is causing it. You can post it on Discord, people there are very helpful!
Panchito Mágico 29 Jun @ 10:13pm 
I like your art, pictures and icons! Sweet mods!

Also, I am getting this: Timberborn.MapMetadataSystemUI.MapMetadataPanel.get_MapNameLocKey(), any ideas? Thanks!
Cheez 20 Mar @ 10:06pm 
no
Luke ✞ Jesus Saves ✞  [author] 20 Mar @ 10:04pm 
Hey I think you are right but as a modder I can't really make any good assets. Could you please provide some good one so I replace this bad art? Thanks!
Cheez 20 Mar @ 5:35pm 
bad art