Model Variants for Decorations

I saw that the trees uses a model_variants-string to change the cq-file when placed on the map. Is this also useable for furniture-decorations? I want to add more diversity to my mod using this code i can add more different models to one single recipe.

But now to my question. A tree once placed can never been replaced on the map. When i add this code to a replaceable model will it change the cq-file every time i change the position?

The code string i refer:

"model_variants": {
     "default": {
        "models": [
           {
              "type": "one_of",
              "items": [
                 "file(small_oak_tree.qb)",
                 "file(small_oak_tree_2.qb)",
                 "file(small_oak_tree_3.qb)"
              ]
           }
        ]
     }
  }
1 Like

No, it will remember which model it used and every time you moved it will have that same model. It is only random the first time, when it is created.

1 Like

Excellent!!! :smiley: just the right thing that i need. Thx

ohhh something seems to be wrong :open_mouth:

i added only in the entity file the same code like used for the tree sampling. but the model wasnā€™t changed but instead he inserted both models sovraposed. this in the picture are two objects.

have i to do some changes also in the ghost file of the item? or what its wrong?

"model_variants": {
         "default": {
            "models": [
               {
                  "type": "one_of",
                  "items": [
                     "file(shelf_herbalist_library.qb)",
                     "file(shelf_herbalist_library2.qb)"
                  ]
               }
            ]
         }
      },

You should only have that model_variants json in the ghost.

If you add to the normal and ghost entities, you will have two models overlapping. You just didnā€™t noticed before because both models were the same. Now that you have random models, you end up with one from the normal and one from the ghost.

To clarify, everything you do in the ghost is added to the normal object. Thatā€™s why you donā€™t need to duplicate code.

2 Likes

This is really neat - and, as always, Bruno provides some excellent help!
Youā€™ve just given me some neat ideas, @pingu! :smiley:

I hope pingu donā€™t mind, but I would like to expand upon their question.
Letā€™s say Iā€™m creating a chair for which I want:

  • 5 different variants of legs
  • 5 different variants of sitting-pads (or cushions)
  • 5 different variants of backrest

@BrunoSupremo (or any one else), do you know if it is possible to set up three similar ā€œrandom selectionsā€ between the 5 models for each respective part of my chair, and have them be combined into one model within Stonehearth (that will always remain as one item)? - or, do I have to create the 125 different models and have the ā€œone_ofā€ selection been written between these 125 models?

While I may not be an expert on this, I donā€™t think the game is set up to handle ā€˜groupsā€™ of objects as a super-objects. So Iā€™m quite sure youā€™d have to do it the tedious way or at least make several of seemingly random combinations, but just avoid making all of them.

Iā€™m curious if Iā€™m mistaken on this though, so if so, please indulge me :wink:.

This is my fear, as well - Iā€™m really hoping Iā€™m incorrect though :slight_smile:
Would ā€œno super-objectsā€ be the case, I think there are work-arounds - however, I fear the only one I can think of would be way more resource-heavy than the tedious making of 125 variants :stuck_out_tongue:

You can.
For example, this is how the goblins are made:

      "model_variants": {
         "default": {
            "models": [
               "file(goblin_body.qb)",
               {
                  "type": "one_of",
                  "items": [
                     "file(goblin_head_1.qb)",
                     "file(goblin_head_2.qb)",
                     "file(goblin_head_3.qb)",
                     "file(goblin_head_4.qb)",
                     "file(goblin_head_5.qb)"
                  ]
               },
               {
                  "type": "one_of",
                  "items": [
                     "file(goblin_armor_none.qb)",
                     "file(goblin_armor_vest.qb)"
                  ]
               }
            ]
         }
      },

First it add the body model. Then one of those list of heads. And later one of the list of outfits.

In your case it would be something like this:

      "model_variants": {
         "default": {
            "models": [
               {
                  "type": "one_of",
                  "items": [
                     "file(leg_1.qb)",
                     "file(leg_2.qb)",
                     "file(leg_3.qb)",
                     "file(leg_4.qb)",
                     "file(leg_5.qb)"
                  ]
               },
               {
                  "type": "one_of",
                  "items": [
                     "file(cushion_1.qb)",
                     "file(cushion_2.qb)",
                     "file(cushion_3.qb)",
                     "file(cushion_4.qb)",
                     "file(cushion_5.qb)"
                  ]
               },
               {
                  "type": "one_of",
                  "items": [
                     "file(back_1.qb)",
                     "file(back_2.qb)",
                     "file(back_3.qb)",
                     "file(back_4.qb)",
                     "file(back_5.qb)"
                  ]
               }
            ]
         }
      },
4 Likes

Amazing - your respons and provided examples are helpful as well as extremely appreciated, Bruno!
Now, I will have to completely re-make the base code of my own mod :slight_smile:

Once again, from the bottom of my heart, thank you!

Keep in mind though that this takes effect when an item is created.
If you have a chair with multiple variations, and you want to build a hall with 10 blue chairs, you will have a hard time doing it, as your crafter will keep doing chairs in red, yellow, green, and other colors, randomly.

2 Likes

Oh, lol! Yes of course - the function you describe would be intended for what I have in mind; nevertheless, itā€™s a good thing that you point it out! xD

Well, I feel dumb now. Of course it would work; as you pointed out, it already works with entities like hearthlings and npcs, which Iā€™d say should actually be more complicated than static items.

Thank you ever so much for correcting my folly, Bruno :sweat_smile:.

2 Likes

Ohhh this idea is amazing!!! :open_mouth:

Just the code i need! Merci xD

Hhhh yes of course you can use it xD

I have seen it on the tree model and was thinking why not using it for some models?

Working now on a update!!

Your mod will turn even more awesome now! :smiley:
Iā€™m also working on an update - over 9000 model-variations and countingā€¦ xD

1 Like

ahahah great @Hamnisu! Canā€™t wait to see it :wink:

1 Like

Just an aesthetic problem. I noticed that when i want to change the position of the placed model the ghost image changes and doesnā€™t combine with the placed item.

Probably this problem has no solution but maybe someone knows how to prevent this

Sorry, I donā€™t quite follow - would it be possible to add an image to display the issue?

ahh my english xD sorry

i try to explain.

before you place a model on the map you see a ghost image of the model (the semi transparent one). after placing it the model changes. you donā€™t see the right model in the ghost-mode. The transparent one changes every time you change place.