Building a random model generator - multiple packs, one entity


#1

Hey! :merry:

I’m working on a statue mod. I already have all the basic parts and the generator works. But I’m trying to solve a problem with “choosing from multiple part packs”. To give an example, there are separate pieces for the body, hair and hands. The generator works well, combining them randomly. But I want the statues to be both depicting males and females, but their parts won’t mix well. So I’m wondering, how would I have one entity, where it would choose from either the male or the female pack and then from the possible pieces? I tried various combinations of the code, but it either did not switch or flat out broke the thing.

I’ll be able to upload my JSON in a few hours if somebody wants to see. I’m just wondering if someone has tried/solved this yet.


#2

Well you can ofc cheat and have two random entities with one recipe. (might also aid in testing)


#3

That’s the plan if crisis hits. I don’t want to have two things in the building editor though. That would cause tons of chaos.


#4

Shit hadn’t thought of that. In that case, Bruno will know XD


#5

could you just make two recipes, one for male and one for female?


#6

Awww that makes me think you could build statues for fallen hearthlings. If it can choose amongst all of the customization options, but then would you also be able to set poses as options as well?


#7

I could, but I don’t want to :stuck_out_tongue: If I don’t find a way of how set this in the generator, then I’m going to do that.


#8

Wow, that would be cool. But that also sounds like LUA. No bueno :joy:


#9

No worries, Rayya knows I don’t do any modding so just figured I’d throw it out there


#10

I’m not entirely clear on what the topic is(I’m sleepy, brain drain from all the code the past week)
Are you making a recipe for a statue that you want to randomly be one of two variants?


#11

Not that simple. Each statue has three parts which have a lot of variants. I need something to randomly switch between two packs of parts. Imagine something like having multiple models of a tree for each season, where the leaves would be a one_of and the trunk would be a one_of, plus instead of default and winter it’s male and female. The problem is, that I need these to be randomly chosen as well. If I wrote the code like that it would only react to the seasonal switcher afaik. To a one_of on that level it did not react. Inserting items {} into items {} did not work…


#12
{
"mixins": "stonehearth:mixins:placed_object",
"type": "entity",
"components": {
  "model_variants": {
        "default": {
			"type": "one_of",
            "models": [
                {
               "type": "one_of",
               "items": [
							
                 "file(m_body/m_body_1.qb)",
                 "file(m_body/m_body_2.qb)",
                 "file(m_body/m_body_3.qb)",
                 "file(m_body/m_body_4.qb)",
                 "file(m_body/m_body_5.qb)",
                 "file(m_body/m_body_6.qb)",

              ]
           },
           {
              "type": "one_of",
              "items": [
                 "file(m_hair/m_hair_1.qb)",
                 "file(m_hair/m_hair_2.qb)",
                 "file(m_hair/m_hair_3.qb)",
                 "file(m_hair/m_hair_4.qb)",
                 "file(m_hair/m_hair_5.qb)",


              ]
           },   
           {
              "type": "one_of",
              "items": [
                 "file(hands/hands_1.qb)",
                 "file(hands/hands_2.qb)",
                 "file(hands/hands_3.qb)",
                 "file(hands/hands_4.qb)",
                 "file(hands/hands_5.qb)",
                 "file(hands/hands_6.qb)",
                 "file(hands/hands_7.qb)",
                 "file(hands/hands_8.qb)",
                 "file(hands/hands_9.qb)",
                 "file(hands/hands_10.qb)",
                 "file(hands/hands_11.qb)",


              ]
           },  
		],
		
            "models": [
                {
               "type": "one_of",
               "items": [
								
                 "file(f_body/f_body_1.qb)",
                 "file(f_body/f_body_2.qb)",
                 "file(f_body/f_body_3.qb)",
                 "file(f_body/f_body_4.qb)",
                 "file(f_body/f_body_5.qb)",
                 "file(f_body/f_body_6.qb)",

              ]
           },
           {
              "type": "one_of",
              "items": [
                 "file(f_hair/f_hair_1.qb)",
                 "file(f_hair/f_hair_2.qb)",
                 "file(f_hair/f_hair_3.qb)",
                 "file(f_hair/f_hair_4.qb)",
                 "file(f_hair/f_hair_5.qb)",
                 "file(f_hair/f_hair_6.qb)",
                 "file(f_hair/f_hair_7.qb)",
                 "file(f_hair/f_hair_8.qb)",
				 
              ]
           },   
           {
              "type": "one_of",
              "items": [
                 "file(hands/hands_1.qb)",
                 "file(hands/hands_2.qb)",
                 "file(hands/hands_3.qb)",
                 "file(hands/hands_4.qb)",
                 "file(hands/hands_5.qb)",
                 "file(hands/hands_6.qb)",
                 "file(hands/hands_7.qb)",
                 "file(hands/hands_8.qb)",
                 "file(hands/hands_9.qb)",
                 "file(hands/hands_10.qb)",
                 "file(hands/hands_11.qb)",


              ]
           },  
        ]	
	  } 
	},
	"render_info": {
		"scale": 0.12
	},
	"mob": {

		"model_origin": {
			"x": 0,
			"y": 0,
			"z": 0
		},
		"region_origin": {
			"x": 0.5,
			"y": 0,
			"z": 0.5
		},
	}
},
"entity_data": {
	"stonehearth:catalog": {
		"display_name": "Tall Tree",
		"description": "This used to be an important person.",
		"icon": "file(statue.png)",
		"category": "decorations",
		"material_tags": ["decoration", "stockpile_decoration"]
	}
}

}


#13

Ooooh man
That mod… You’re going to love one of the new things in 0.9.3 :stuck_out_tongue:


#14

Does it have to do something with marble? XD


#15

Yes :smiley:

Let’s just say that random statues and that feature can be combined in a very nice way with a simple json mixinto :smiley:

(so your mod can be super compatible with ACE in a cool way)


#16

Lol, I’m absolutely gonna try that… after I figure this out :joy:


#17

I’ll PM you with some hot info XD


#18

OMG I’VE ACCIDENTALLY FIXED IT. Thanks for your participation everyone :joy:

No… wait… I did not… FFFffff