Question: How do you add objects to r188?

#1

I know about the modelling, but I’m having trouble of adding an item into the game, does anyone know how to do this?

1 Like
Starting to develop mods!
Modding Samples
How do you add harvestable items?
Need help modding
#2

Whats the item? do you mean add a brand new item as in modding? or just adding an item like a table to the world?

Dryad Model (WIP)
Teach me to mod :blush:
#3

Hi

Here’s the break down currently for r180, feel free to ask anyone if you have any more questions :wink:

edit:
I assumed craftable, if not let us know. World gen is somewhat similar, but still very doable at this point.

Step 1 - Basic Setup


Goto your Stonehearth mods folder, if you installed to the default location this should be

x86 - 32bit
C:\Program Files\Steam\SteamApps\common\Stonehearth\mods

x64 - 64 bit
C:\Program Files (x86)\Steam\SteamApps\common\Stonehearth\mods

Now create a folder for your mod, for this example I’ll create a folder called r180mod.

Next create a file inside your mod folder, mine is r180mod, called manifest.json.
Open your manifest.json, we will be using it in a little bit.

Now lets add you items files into our mod folder (r180mod).

For conventions sake, we add a “entities” folder, “entities” will be used to store all the files for items we add to the game. “entities” should be place just inside our r180mod folder.

Next add another folder for your mod item inside the entities folder. I will call mine “my_mod_item”.
Now add any .qb files .png files that you’ve made for that item inside that folder.

Our mod file structure so far

- r180mod
  ----manifest.json
  ----entities
      ----my_mod_item
          ----my_mod_item.qb
          ----my_mod_item_iconic.qb
          ----my_mod_item.png

Let me break down the files I’ve added

my_mod_item_iconic.qb - The stockpile version of my model, I believe it’s 10x10x10 voxels
my_mod_item.qb - The actual fullsize model of my item
my_mod_item.png - The picture displayed in the crafting window.

Step 2 - Basic Manifest set up


Now lets go back to that manifest.json file, this file is used to tell Stonehearth many things about files you would like to it load, in particular we are concerned with the mixintos and aliases properties.

mixintos - used to combine an existing file with another
aliases - allow us to give a simplified name for our mod item, just to simplify referencing it latter on.

Here is an example of a basic mod manifest

{
    "info" : {
          "name" : "r180mod",
          "version" : 1
    },
    "aliases" : {
    },
    "mixintos" : {
    }
}

You should copy and paste this to your manifest.json.
Just replace the “name” value with you mods folder name.

Lets add an alias for our mod item

{
    "info" : {
          "name" : "r180mod",
          "version" : 1
    },
    "aliases" : {
          "my_mod_item" : "file(entities/my_mod_item/my_mod_item.json)"
    },
    "mixintos" : {
    }
}

Step 3 - Mixintos/Recipes


Next in order for your item to be craftable in the game, we must mixinto a classes recipe list. In order to do so we must have the files needed for the mixin and know where to mix into.

Where - This depends on which class will crafting your item, all classes can be found in stonehearth/jobs
The Files - We will go over this together

Just follow along, I explain everything in the end.

Lets use the carpenter for this example, lets create a new folder to hold all of our mixintos called “mixins”, place this inside r180mod.

Inside our mixins folder lets create a file called “carpenter_recipes.json”.

Now step back to the r180mod folder and create another folder called "recipes", inside this folder create another file called “my_mod_item_recipe.json”.

carpenter_recipes.json - Will be used to specify all of the recipes we’d like to add to carpenters current recipe list.
my_mod_item_recipe.json - Will be used to specify the acutally recipe for our item.

Our mod file structure so far

- r180mod
  ----manifest.json
  ----entities
      ----my_mod_item
          ----my_mod_item.qb
          ----my_mod_item_iconic.qb
          ----my_mod_item.png
  ----mixins -NEW
      ----carpenter_recipes.json -NEW
  ----recipes -NEW
      ----my_mod_item_recipe.json -NEW

Even though we have written anything lets update our manifest to tell Stonhearth that we’d like to mixin a file.

{
    "info" : {
          "name" : "r180mod",
          "version" : 1
    },
    "aliases" : {
          "my_mod_item" : "file(entities/my_mod_item/my_mod_item.json)"
    },
    "mixintos" : {
           "/stonehearth/jobs/carpenter/recipes/recipes.json" : 
              ["file(mixins/carpenter_recipes.json)"]
    }
}

mixintos are specified target : file to add

/stonehearth/jobs/carpenter/recipes/recipes.json - The file that holds all the carpenter recipes.
[“file(mixins/carpenter_recipes.json)”] - Our carpenter recipe file.

Lets set-up our carpenter_recipes.json file now. Match yours to this, make any adjustment for differences in names.

{
   "craftable_recipes" : {
      "furniture" : {
         "recipes" : {
            "my_mod_item" : {
               "recipe" : "file(/recipes/my_mod_item_recipe.json)"
            }
         }
      }
   }
}

There are many catergories for where to add items, I chose furniture. Take a look at
stonehearth\jobs\carpenter\recipes\recipes.json, if you like to use a different catagory, you can even add your own.

{
   "craftable_recipes" : {
      "$catagoryname" : {
         "ordinal" : 5, (5 and up I believe)
         "name" : "Display Name",
         "recipes" : {
            "my_mod_item" : {
               "recipe" : "file(/recipes/my_mod_item_recipe.json)"
            }
         }
      }
   }
}

With this out of the way, lets move on to our actual recipe. Open up my_mod_item_recipe.json

{
   "type":"recipe",

   "work_units"  : 3,
   "recipe_name" : "My Super Mod Item - Display Name",
   "description" : "Better than every item.",
   "flavor"      : "Stonehearthians will think this line of text",
   "portrait"    : "/r180mod/entities/my_mod_item/my_mod_item.png", 

   "ingredients": [
      {
         "uri" : "stonehearth:furniture:not_much_of_a_bed",
         "count" : 1
      },
      {
         "material" : "wood resource",
         "count" : 1
      }
  ],
  "produces": [
      {
         "item":"r180mod:my_mod_item"
      }
  ]
}

Lets break it down, I’ll go over only the ones that are not self explanitory.

“work_units” : 3 - How long to craft

“ingredients”: - This one’s a bit complicated, for each seperate ingredient you must specify { }'s, from here you have 2 options, require a specific item, or require that the item has a specific material tag.

“produces”: - specifies the return item from the crafting process

That should be good, final stretch :wink:

Step 4 - Entity_Forms and Iconic/Ghost


In our manifest’s aliases we specified
"my_mod_item" : "file(entities/my_mod_item/my_mod_item.json)"

Go ahead and create that file, along with it create 2 other files,

my_mod_item_iconic.json
my_mod_item_ghost.json

Our mod file structure so far

- r180mod
  ----manifest.json
  ----entities
      ----my_mod_item
          ----my_mod_item.qb
          ----my_mod_item_iconic.qb
          ----my_mod_item.png
          ----my_mod_item.json - NEW
          ----my_mod_item_iconic.json - NEW
          ----my_mod_item_ghost.json - NEW
  ----mixins
      ----carpenter_recipes.json
  ----recipes
      ----my_mod_item_recipe.json

For anything below rememeber to replace filenames/paths to match you own.
For my_mod_item.json

{
   "type" : "entity",
   "mixins" : "file(my_mod_item_ghost.json)",

   "components": {
      "stonehearth:entity_forms" : {
         "iconic_form" : "file(my_mod_item_iconic.json)",
         "ghost_form" : "file(my_mod_item_ghost.json)",
         "placeable_on_ground" : true
      },
      "region_collision_shape": {
          "region": [
            {
               "min" : { "x" : -0.5, "y" : 0, "z" : -0.5 },
               "max" : { "x" :  1.5, "y" : 1, "z" :  1.5 }
            }
         ]
      }
   },
   "entity_data" : {
      "stonehearth:net_worth" : {
         "value_in_gold" : 30,
         "rarity" : "common",
         "shop_info" : {
            "buyable" : true,   
            "sellable" : true,
            "shopkeeper_level" : 1,
            "shopkeeper_type" : "caravan"
         }
      }
   }
}

Things to note, (if you need more specific info feel free to ask)

“placeable_on_ground” - There is also “placeable_on_walls”

“entity_data” - I am completely guessing, is used by other entities, ie a bed specifies “stonehearth:bed” : {}, allows other entites, to know it’s a bed.

“region_collision_shape”: - bounds of the object, I am guessing again but I think they are based on Stonehearth cube size which is 1 voxel. Hard to test, can’t micro.

Next up my_mod_item_ghost.json

{
   "type": "entity",

   "components": {
      "model_variants": {
         "default": {
            "models": [
               "file(my_mod_item.qb)"
            ]
         }
      },
      "unit_info": {
         "name": "My Super Mod Item",
         "description": "Whoo wa weee wa",
         "icon" : "file(my_mod_item.png)"
      },
      "stonehearth:material" : {
         "tags" : "wood furniture crafted"
      },
      "mob" : {
         "model_origin" : { "x": 0, "y": 0, "z": 0 },
         "region_origin" : { "x": 0.5, "y": 0, "z": 0.5 }
      }
   }
}

Notes

“tags :” - Change this to what ever you want
"model_origin" : - Used to create a display offset for the model, I haven’t test but thats what it should be. “region_origin” : - I haven’t test but I would guess a position offset, ie .5 half the width of a StoneHearth cube size, which is 1 voxel. ie x .5, y 0, z .5 , centered in the xz plane.

Finally my_mod_item_iconic.json

{
   "mixins": "stonehearth:mixins:item_properties",
   "type": "entity",
   "components": {
      "item" : {
         "category" : "furniture"
      },
      "model_variants": {
         "default": {
            "models": [
               "file(my_mod_item.qb)"
            ]
         }
      },
      "mob" : {
         "model_origin" : { "x": -0.05, "y": 0, "z": 0.05 }
      }
   }
}

Notes

“category” : “furniture” - I would guess this is used for sorting in stock piles

Debugging Problems


We are only human, so we are bound to make mistakes. Here’s some tips

Check the log

C:\Program Files (x86)\Steam\SteamApps\common\Stonehearth\stonehearth.log
it can detail whats going wrong, other’s can help you if you can’t understand it.

Check your json file, very very common mistakes happen here, ie a " , " where it does not belong

Can verify any errors in you json files

Typos and Wrong Paths
Keep naming conventions,

“comfy_bed_red”
“comfy_bed_blue”
“comfy_bed_green”

Don’t do this

“comfy_red_bed”
“bed_comfy_blue”
“green_bed_comfy”

Name things consistently, this helps identify typos and remember what you have named things.
Goes without saying, but I figured I was mentioning common problems, this is one you will likely run into.

Trolled by load game

I have no idea what causes this, but it is very very frustrating. My only guess is that items ui info is somehow reliant on some of your save, that if you change an items display name, the save fails to recognize that the paths have changed, and just amuses it’s the same, causing to fail to find the path. Start a new game to make sure you’ve really done something wrong.

Ask the community, people are always around and willing to help.

Best of luck

19 Likes
StoneVox 3D - Community Voxel Modeler for StoneHearth
I don't know what's wrong with my mod
Coding bug eradication needed. aka help ;)
A lot of questions aliases/overrides/mixintos
[MOD] Blacksmith and Ores
[Tutorial] Adding mining resources
#4

Thank you very much for that, I will be reading that in detail tomorrow as I’m working today but I caught what you said about the top.

I have made more plant types, farmable and to be found spawned in the game world. I also have items that I want to be made by the carpenter and at the moment new types of roads (that can’t be walked on if possible.)

New tree’s that can hopefully be added to the spawn, all that jazz.

#5

wow, well done @honestabelink!! thanks for putting this together… should prove very useful to other budding modders…

+5 internet points to you my good man! :+1:

5 Likes
#6

Very nice little guide, me likey!

Just want to point out that in the manifest, there is no requirement that info.name has the same name as the mod folder. You could write in whatever you want there, of course it should be the same as the mod folder. But if your folder is called “my_mod_r180” you can name it “My Mod r180” in info.name.

1 Like
#7

Thanks for clarifying.

From here on I will reference an onion as the crop I’m adding, my onion will also grow in the wild.

Farmable Crops


We will cover world gen in the next section first lets get your plants into the game :wink:

Lets go over what files you will need to add a new crop to the game. I will also go over optional choices you have.

.qb’s for each stage of growth for your crop, from little stem to fully grown, optionally you can include a withered version.
I don’t believe there is a limit to amount of stages.

.png - This will be shown in the farming ui, where players pick the crop they want to grow.

.json - This will specify our crop entity, will provide info like, growth stages, growth rate, what is harvested.
Optionally I will go over making your crop placeable, this will require some additional json files.

.lua - Optionally, we can specify a script to control plant growth, but it’s not required for normal growth.

Now lets setup our file structure for the new crop and add all of the files we need.

In our entities folder create a new folder “crops”, then create another folder, I will call mine “onion”.

Inside onion folder, place all .qb’s you have that make up the crop, your .png for farming ui, and create onion.json.

- r180mod
  ----manifest.json
  ----entities
      ----crops - NEW
          ----onion - NEW
              ----onion.json - NEW
              ----onion.qb - NEW
              ----onion.qb - NEW
              ----onion.qb - NEW
              ----onion.png - NEW

Next lets add an alias for our crop to our manifest

"aliases" : {
          "onion:crop" : "file(entities/crops/onion/onion.json)"
},

Even though we haven’t made the file yet, lets add a mixinto to our manifest, this will be used to add our crop to the farmers plantable crops.

"mixintos" : {
       "/stonehearth/services/server/farming/data/initial_crops.json" : 
          ["file(mixins/farmer_crops.json)"]
}

Lets add that file now, goto the mixins folder, and create the file “farmer_crops.json”.

Open up farmer_crops.json.

{
    "stonehearth:kingdoms:ascendancy": [
        {
            "crop_type": "r180mod:onion:crop",
            "quantity": 5
        }
    ],
    "stonehearth:kingdoms:rayyas_children": [
        {
            "crop_type": "r180mod:onion:crop",
            "quantity": 5
        }
    ],
    "stonehearth:kingdoms:northern_alliance": [
        {
            "crop_type": "r180mod:onion:crop",
            "quantity": 5
        }
    ]
}

Just replace r180mod:onion:crop with your alias.

With that done lets move onto the actual json, open up onion .json.

{
   "type": "entity", 
   "components": {
      "model_variants": {
         "default": {
            "models": [
               "file(onion_3.qb)"
            ]
         },
         "onion_1": {
            "models": [
               "file(onion_1.qb)"
            ]
         },
         "onion_2": {
            "models": [
              "file(onion_2.qb)"
            ]
         },
         "onion_3": {
            "models": [
               "file(onion_3.qb)"
            ]
         }
      },
      "render_info" : {
         "scale" : 0.13
      },
      "mob" : {
         "model_origin" : { "x": -0.05, "y": 0, "z": 0.05 }
      },
      "unit_info": {
         "name": "My Super Crop", 
         "description": "Fast-growning, and super nutritious crop.", 
         "icon" : "file(onion.png)"
      },
      "stonehearth:crop" : {
         "resource_pairings" : {
            "onion_3": "stonehearth:food:corn:amazing_corn_basket"
         }, 
         "harvest_threshhold" : "onion_3", 
         "plant_overlay_effect" : "/stonehearth/data/effects/plant_crop_overlay_effect/plant_crop_overlay_effect.json" 
      }, 
      "stonehearth:growing" : {
         "growth_period" : "1h",
         "growth_stages" : [
            {
               "model_name" : "onion_1",
               "name": "Not Super Yet", 
               "description": "Not high-stakes gambling."
            },
            {
               "model_name" : "onion_2",
               "name": "Better but Not Super", 
               "description": "Not edible yet!"
            },
            {
               "model_name" : "onion_3",
               "name": "My Super Crop", 
               "description": "Extremely satisfying to eat."
            }
         ]
      },
      "stonehearth:material" : {
         "tags" :  "crop onion"
      }
   }
}

This can be overwhelming to look at but it’s really not that bad.

Let’s take a look at model_variants


"model_variants": {
     "default": {  - VARIANT NAME
        "models": [ - MODELS KEY
           "file(onion.qb)" - OUR MODEL VALUE
        ]
     },

model_variants is used to specify each stage of our plants growth, to add a new variant simply add a new variant name along with the models key, followed by a list of possible files. I’m guessing if you wanted you could specify multiple files per variant, that way all plants wont look the same at the same stage.

Let’s take a look at stonehearth:crop


  "stonehearth:crop" : {
         "resource_pairings" : {
            "onion_3": "stonehearth:food:corn:amazing_corn_basket"
         }, 
         "harvest_threshhold" : "onion_3", 
         "plant_overlay_effect" : "/stonehearth/data/effects/plant_crop_overlay_effect/plant_crop_overlay_effect.json" 
      }, 

Here we specify some information about harvesting our crop. I have specified my crop when haverested in stage onion_3 will return “stonehearth:food:corn:amazing_corn_basket”. You can specify any item you want here, you can also add multiple resource_pairings. Later on I will show how to make your crop ediable, and return an edible entity.

“harvest_threshhold” - I am guessing, is the minimum stage for harvesting.

Let’s take a look stonehearth:growing


"stonehearth:growing" : {
     "growth_period" : "1h",
     "growth_stages" : [
        {
           "model_name" : "onion_1",
           "name": "Not Super Yet", 
           "description": "Not high-stakes gambling."
        },

Here we specify how long each stage takes to grow, ie 3 stages at 1h growth_period = 3h fully grown. Along with display name and description for each stage. growth_stages.model_name should match your model_variant names.

If you need to mess with the growing, add this right below “growth_period” : “1h”, create the lua file too.
“growth_check_script” : “file(onion.lua)”,

local onion={}
function onion.growth_check(entity,target_growth_stage,growth_attempts)
   return target_growth_stage
end
return onion

Your lua file should implement this function, and return a number between 1 and your highest growth stage, I am guessing again about the return.

That should do it, see if your crop is available to the farmer, just a reminder the loading bug happens here too. If you are sure you have done things right, and it’s not working, try it in a new game.

World Gen with EntityClusters


Entity clusters are simple way to have your plants spawn throughout the world, it is used, for example for the current flowers in the game. Along with other things like animal spawns.

Lets get to it :wink:

We will need to specify a mixin to add our plant to the world gen. Even though we haven’t create the file lets go ahead and specify the mixinto. Also lets add an alias for the plant version of my onion, the plant version is the one that grows in the wild.

"aliases" :   {
  "onion:plant" : "file(entities/plants/onion/onion.json)"
},

"mixintos" :  {
  "/stonehearth/scenarios/scenario_index.json":
            ["file(mixins/plant_fields.json)"]
}

Lets create the folders and files we need now

Goto your mixins folder and create plant_fields.json.
Goto your entities folder, create a new folder called plants, then create another folder called onion,finally create a new file called “onion.json”.

Our file structure so far

- r180mod
  ----manifest.json
  ----entities
      ----plants - NEW
          ----onion - NEW
              ----onion.json - NEW
 ----mixins
     ----plant_fields.json - NEW

Open up plant_fields.json.

{
   "static" : {
      "scenarios" : [
         "file(/terrain/onion_field/onion_field.json)"
      ]
   }
}

This will add our plant field to the world gen, we are missing onion_field.json, lets create it now and the containing folders.

Inside our mod folder create a new folder called terrain, create another folder called onion_field, then create onion_field.json, finally open onion_field.json.

Our file structure so far

- r180mod
  ----manifest.json
  ----entities
      ----plants
          ----onion 
              ----onion.json
 ----mixins
     ----plant_fields.json
 ----terrain - NEW
     ----onion_field - NEW
         ----onion_field.json - NEW

Open up onion_field.json

{
   "mixins" : "/stonehearth/scenarios/static/entity_cluster",
   "name" : "onion_field",
   "category" : "terrain", 
   "habitat_types" : ["plains"],
   "size" : {
      "width" : 3,
      "length" : 3
   },
   "weight" : 20,
   "habitat_types" : ["plains", "foothills"],

   "scenario_info" : {
      "entity_type" : [ "r180mod:onion:plant" ],
      "entity_footprint_length" : 1,
      "quantity" : {
         "min" : 1,
         "max" : 6
      }
   }
}

Mostly straight forward… besides

habitat_types - plains, foothills, mountains, forest
weight - higher value more likely to place over another with a lower weight.

Lets move on to r180mod/entities/plants/onion.json, open it up.

{
   "mixins": "stonehearth:mixins:plant", 
   "type" : "entity",
   "components" : {
      "mob" : {
         "mob_collision_type" : "clutter"
      },
      "unit_info" : {
         "name": "Wild onion", 
         "description": "This Onion is the Best."
      },
      "model_variants": {
         "default": {
            "models": [
               "file(onion.qb)"
            ]
         },
         "depleted": {
            "models": [
               "file(onion_harvested.qb)"
            ]
         }
      },
      "stonehearth:renewable_resource_node": {
         "resource": "stonehearth:resources:fiber:silkweed_bundle",
         "renewal_time" : "1h"
      }
   }
}

Things to note

If your plant does not re-grow, remove

 renewal_time" : "1h"
 "depleted": {
     "models": [
        "file(onion_harvested.qb)"
      ]
  }

My fully grown onion model was onion_3.qb, you can reference it here too. So not to duplicate files around.

 "default": {
     "models": [
        "file(/entities/crops/onion_3.qb)"
      ]
  }

That should be good, give it a try. :wink:

Side Notes


If you want your crop to do these three things

  • grow in the wild
  • be farmable
  • be placeable

You must create a specific entity separate from the crop version and the plant version. This entity should match my example on how to add a craftable item, just without the crafting part, ie it should contain the entity_form component, and specify both ghost and iconic forms, along with the material and mob components.

example
entities/onion/onion.json - placeable
entities/crop/onion/onion.json - crop
entities/plants/onion/onion.json- wild plant

Next change the harvested return item from the crop and wild plant versions to return your placeable version. Don’t forget to alias your placeable version.

Whats left

  • Ediable Entities- very straight forward, maybe I’ll have time for a quick post tommorrow, I am sure by this point you won’t need such detailed posts, let me know though.
  • Custom Trees - I know nothing about, I’ll look into it, probably after New Years
  • Unwalkable roads - Design choice seems counter perductive and confusing for players, but I’ll leave you to your own creative style ;), though I am not sure it’s possible, I have no idea how roads work, I’ll look into it, probably after New Years

Best of luck

8 Likes
#8

Unwalkable roads could be cheated by just giving them a large collision box, same as a wall for example.

#9

Looking quickly, this is seeming like a viable way, but would require overrides to lua files, maybe some js.

,
"movement_modifier_shape" : {
   "modifier" : -0.75
}

slows them down 75% while walking on the road

I don’t get why it does not un-prioritize them from the pathfinder. Maybe it’s caused by Radiant assuming roads are always a speed benefit at this point, not actually taking into account the speed modifier value. Does anyone know where they pull the pathfinder weights from, or are they on the c++ side with the rest of the pathfinder?

#10

Great guides @honestabelink :thumbsup:

For the roads, have you tried a number above 1? Maybe the pathfinder tries to find a way through low numbers. 0,25 does make it lower also if it is multiplied.

#11

Hey I’ve gone through your guide today, not the farming part just the craftable item part and I can’t see to get it into the carpenters craft menu. I’ve got two errors from the JSON checker if you don’t mind taking a look.
[beehive.json pastebin][1]
[manifest.json pastebin][2]

Maybe that’s the reason why it’s not showing up? I’ll double check my file structure again with your guide but I’m pretty sure I’ve got that right. Enjoy your christmas and we’ll carry on whenever anyones free if that’s okay.

Thanks again. [1]: { "type": "entity", "mixins": "file(beehive_ghost.json)", "compon - Pastebin.com
[2]: -beehive----manifest.json----entities----beehive----beehive.qb----beehive_iconic - Pastebin.com

#12

Well if the checker say it is wrong, it probably is :smile:
You have a comma too much in the beehive.json (line 8) after
placeable_on_ground": true
and some weird json write-up above your info in the manifest. Just what the json checker says. Remove those and you are probably fine :blush:

1 Like
#13

OOOOOOOO It’s showing up now!

My problem was the comma and I removed all that ---- stuff which I thought was supposed to go into the manifest.json, it was just @honestabelink trying to visualize the directories for me.

Brilliant, thanks :smiley:

It was going so well until I tried to make the item.

1 Like
#14

Just to extend what @Miturion said,

beehive.json

replace your "stonehearth:entity_forms": with this

    "stonehearth:entity_forms": {
        "iconic_form": "file(beehive_iconic.json)",
        "ghost_form": "file(beehive_ghost.json)",
        "placeable_on_ground": true
       
    }, 

You had an extra comma after “placeable_on_ground”: true.

manifest.json

remove this

-beehive----manifest.json----entities----beehive----beehive.qb----beehive_iconic.qb----beehive.png----beehive.json-NEW----  beehive_iconic.json-NEW----beehive_ghost.json-NEW----mixins----carpenter_recipes.json----recipes----beehive_recipe.json

This is not part of the JSON.

JSON format rundown

JSON works with a the idea of key value pairs, for example.

"key" : "value"

To start a json file we specify an array of keys, we do this by using,

{
}

an array can be looked at like a list

We can add key value pairs like so

{
     "key1" : "value1"
}

To specify another key value pair we add a comma to the previous line

{
     "key1" : "value1",
     "key2" : "value2"
}

Note key1’s line ends with a comma.
Note key2’s line does not end in a comma as it is the last key value pair, in the array.

In certian situations keys may need to contain multiple values, in these cases we specify another array

{
     "key" : "value",
     "key2" : "value2",
     "key_multiple_values" : { 
            "key1" : "value1",
            "key2" : "value2"
     }
}

Same rules apply about commas, if we wanted to add another key value pair after “key_multiple_values”

{
     "key" : "value",
     "key2" : "value2",
     "key_multiple_values" : { 
            "key1" : "value1",
            "key2" : "value2"
     },
     "key4" : "value4"
}
4 Likes
How do you add harvestable items?
#15

your .qb is compressed, I believe Stonehearth will not load it. You’ll have to re-export your .qb’s with the compression checkbox un-checked.

edit also

Z-axis option to ‘Right handed’.
Enable VisibilityMaskEncoding

3 Likes
#16

Finally! Got it on my fourth try. Thanks for this walkthrough! It gave me something to do to get through this food-coma!!

I’m hoping that’s a water pot and not the carpenter’s spit bucket :anguished:

NOTE:
In your example code, line 8 of item.json has that extra comma. Anybody copying from your example will get the same error @thomasbiggin and myself were experiencing.

Thanks again, and Merry Christmas!

5 Likes
#17

I remember when I entered Ludum Dare 31, the make-a-game-in-a-weekend thing. I created my level format in JSON, but I couldn’t get my parser to work. I spent hours and hours of my 48/72 hours on trying to make the thing work. Then I found out I had an extra comma, or was missing a comma, or something. No wonder my JSON parser couldn’t work, if I was feeding it invalid JSON! Short story short: I didn’t get my game finished on time.

Moral of the story: Always use a JSON validator before putting in your JSON. Always.

2 Likes
#18

Thanks for the catch, :wink: fixed.

It’s funny how it’s always such little things we waste hours upon hours trying to solve. When I as implementing raycasting for StoneVox I failed to remember lwjgl flips the y plane, causing my ray to invert against the rotation of my camera. I sat there for hours and hours looking over and over my math, just to find all I had to do was multiple the camera look vector y by -1. :unamused:

2 Likes
#19

Hey Guys,

It’s brilliant to see my own models in the game, I can’t wait to get it out there and hopefully people will benefit from them. I do have some more questions though if you don’t mind asking.

As you can see in the picture below me, this is the full whammy beehive model that is used when placed on the ground, but my beehive_iconic.qb is 10x10x10 but still displays the full model in the stockpile. I don’t know why?

This is the iconic version (exported)

The beehive object has a matrix of 30x30x30 in Qubicle so how would I get the center of the object to be placed where I click on the ground, What happens now is I click on the ground and instead of it being placed in the middle of where I click, it moves up and right 1 voxel and half.

1 Like
#20

It’s hard to say what going on without seeing any files, try this if you are still having trouble private message me your beehive.json beehive_iconic.json

This would suggest to me that your beehive_iconic.json might be referencing the full size model, if not try opening the iconic model in Quibicle, just to make sure the file is right. If the file is right I would then suggest taking a further look at your beehive.json, making sure iconic_form is properly set.

try this in your beehive_iconic.json
"model_origin" : { “x”: -0.05, “y”: 0, “z”: 0.05 }

other than that, make sure that when you exported, your beehive should be at position -15,0,-15.

Looking good so far :wink:

Edit :
I don’t know this for a fact, I am guessing, I could go and test it, but here’s my thought process now.

In your beehive_ghost.json we set “region_origin” : { “x”: 0.5, “y”: 0, “z”: 0.5 }, ie half a cube offset.
Since your model is 30x30x30, we export at -15,0,-15 to get it as close to center as the .qb file format will allow for. From here “region_origin” : { “x”: 0.5, “y”: 0, “z”: 0.5 } does the final shift to get it centered.