I need a scripting help

Hello there, You may have seen me in “Anyone thought of alchemy?”, Ya… I need help with scripting,If anyone is willing to help or teach me a couple of tricks that’ll be great, I have the models, now I need the scripts.

{
“type”: “entity”,
“components” : {“stonehearth catalog”: {
“display_name”: “Emerald Tablet”,
“description”:“An Ancient tablet made of Emerald and has alchemist rune words”,
“icon”: “file(emerald_tablet.png)”, }
}
}
}
“model_variants”:{
“default”: {
“models”: [
“file(emerald_tablet.qb)”{

           }

This is how I learned it:

Begin with a mod that adds items into the game.
Step 1: make your art.
You only need to go as far as to have a model.

Step 2: Get your model in the game.
For this, you download the starter_mod_basic, which has all the functioning mechanisms you need. Then, you simply and only replace the wooden piggy bank with your item. Remember that your item even needs to be called wooden_piggy_bank.qb, or whatever the name is. Then you can install it in your mods folder and see your model in the game.

Step 3. Get to know your material
A good exercise (that is, the exercise that helped me a lot, there might be better ones) is to now start morphing the startermod into your own, complete with name changes of the folders and and ending with the name-change of the mod. At the end of step 2, you’ll notice you had only a bare-bones version of your model in the game, no representative recipe, no iconic form, etc. You do this exercise to learn how everything is interwoven, how all the references play out, and what is specified where. Tip: I highly recommend morphing one detail at a time, and checking if you haven’t broken stuff every time you change something. If you have broken stuff, you should fix it immediately, both to know what you are doing wrong (might sometimes be little typo’s), learn how to fix it, and to not loose focus to other things, which will make everything look more complicated.

Step 4. Learn how to steal.
If the item you had in step 3 required a separation between a placed version and an iconic version, you’ll probably already have done this, (I believe). What I mean is this. For every featurre that is not in the mod, you look at how the stonehearth main mod does it. (this is stonehearth.smod, and you have it in the mod’s folder if you have stonehearth itself, it is what stores the game.). For this you use your knowledge of the behaviour of vanilla stonehearth items. You simply copy the tactics, fix all the references for what you need, and then it should work.

Step 5. Search and ask on the forums.
If you really don’t come any further, you still have the forums. search first if some other modder has run against the issue before (I know i have my share of threads hunting for annoying-bug-hunting threads). And if not, you can always ask.

With all that, I want to say: Good Luck.

P.S. .jsonlint is your friend in catching .json typo’s

1 Like

To help you with step 2.

First, the manifest. It sits right at the main folder of your mod, and it has to be there. The manifest is the table of contents of your mod, it describes what is in the mod. Specifically four things:

  1. The basic stuff. You’ll see the mod name and the version number. DO NOT MESS with the version number, or your mod will break. I believe the dev’s use it to determine if mods can even be read the way the game expects them to, which in practice means that they change the required version number every time major changes happen to the modding infrastructure. You don’t need to know all that, (after all, I believe this is how it works), you should just know not to mess with it.

  2. Aliases: these are shorthands for certain files in your mod. It allows you te reference the bronze ingot from the original stonehearth game by saying “stonehearth:refined:bronze_ingot” instead of writing down the excact file location. It is also useful if said file location is subject to change, because references using aliases do not care about where the .json is.
    you specify an alias by

    “aliases” : {
    “your_alias_name” : “file(exact/location/of/the/file.json)”
    }

remeber that if you folder structure changes, you’ll still have to change it in the manifest, but that is just one findable spot, as supposed to many possbily-forgotten spots.

  1. Mixins and overrides:
    Mixins are your way of adding code to other .json files. (You’ll see stonehearth doing it when you use item_ghost.jsons next to your item.jsons, the game adds all the code from item_ghost.json to item.json). It is your way of manipulating other mods, including the main game, al from your lazy couch, your mod own mod folder. You specify these in the manifest using:

    “mixintos” : {
    “file/that/you/want/to/mix/into” : “file(the/file/you_want/to_mix/in_either_as/alias/or/exact/file_path.json)”
    }

You can also mixin some code from another file into your own file using a “mixin”, instead of a “mixinto”, but you don’t need to specify that in the manifest, you’ll just see in the the file itself. But it might only work in certain cases.

The other option is an override. Where a mixin adds code to a file, an override, well, overrides it. It completely replaces a file. This is used, for example, to replace stock models, but please don’t use it for other stuff unless you know what you are doing. The dev’s mainly warn for this. You specify an override as follows:

  "overrides" : {
     "file/that/you/want/to/override" : "file(the/file/you_want/to_override/with.json)"
  }
  1. Default_locale:
    Your locales.json is the file that contains all the text that the player will see. Instead of hardwiring it in your .json code, it is convention to reference a certain line in the locales file, where the actual text is. This is so that translators can make a new, translated file and replace that with your own, effectively changing the language in which the entire mod is written. I’m sure you can peek around in stonehearth.smod to find out how this works. In short, the default_locale in the manifest specifies what file the locale file is in your mod.

Also, to know how .json works, I believe there is a stream somewhere from @sdee , where she explains how .json works.

3 Likes

Alright thank you :smiley:, This will help in the future.