Questions about biomes values and how to edit them

I have many questions and I think I bugged the game multiple times while editing biomes :slightly_smiling: I don’t know how many here will be able to help me :frowning:

Let’s start: (This will be a loong post, sorry)

		"depth": {
			"shallow": 5,
			"deep": 10
		},

There is shallow and deep water values, so if you have shallow 5 and deep 10, this means that from the shore you need a ladder 5 blocks tall to reach the shallow bottom of your lake, then another 5 blocks tall to reach the deep part of it starting from the shallow part.
The problem is there is a hard limit, I can’t use shallow 1 or else the game crashes, but I could use shallow 0, is in my archipelago mod, and the game simple ignores it and generates only the deep parts. The strange thing is I actually managed to bug a few times a value of 1 (can’t reproduce), and the result was no water at shallows cause the water level was not high enough for it, so it ends up as dry land, cause water levels is always 2 blocks below the default grass areas.

What I want is, to have water level rise by 1 block (so it touches the edge of grass blocks, not just the dirt below it), and have a shallow level of 1. This means that a hearthling would be able to simple walk down into the water, with out the need to carve a stair.


Terrain scars… How are those generated? I know it is related to the amount of plains (flat areas) you have, but how can I remove they all? They bug though water creating strange visual land errors…
https://discourse.stonehearth.net/uploads/short-url/mI1nls311wZ0k6mcy4eC4h5iBNF.png


How this part exactly works?

"plains": {
         "step_size": 2,
         "valley_count": 1,
         "step_count": 2
},

I could rise valley_count a little to no effect, but when I rise above 5 (I think), it bugs the game.
Everything else bugs the game if rised or lowered.
There was one time that messing with these values actually raised water level so high the water was almost flooding into land. Can’t reproduce anymore. And I have no idea how the two correlates…


How do I spawn plants in the water? I guess this is not possible with the json alone and would require lua changes too, right?


Is there a way to control bunny statues? I guess once more is a lua thing…


I know this one is not from a finished feature, but palettes from different season don’t work in game, only at the map location chooser. For example, I added winter palette, and put the initial season as winter. Wen choosing the start location, the mini-map was all white according to my winter palette, great, but as the game loaded, it started in spring and used that palette instead.
It would be cool if as times go on, the palettes would slowing shifting from one color to the next, so we could see the green from spring fading into white from winter.
But, this is for the future I know, just a little bug report about the season always stuck into spring.


`	"stonehearth:trees:oak:small" : {
		"placement_type" : "dense",
		"parameters" : { "grid_multiple" : 2, "item_density" : 0.5, "exclusion_radius" : 2 },
		"mountains" : {
			"placement_type" : "single",
			"parameters" : { "ground_radius" : 2, "exclusion_radius" : 3 }
		}
	},

How this works exactly?` I understand the “parameters” : { “grid_multiple” : 2, “item_density” : 0.5, “exclusion_radius” : 2 }, option:
The grid chose a random spot to create the items, the grid_multiple values is the distance it will work, so a value of 2 will look into 2 blocks in every direction (effective 5x5 area) and spawn items in there based on item_density value. But what is the exclusion_radius for? I messed with it and saw no difference.
And the “parameters” : { “ground_radius” : 2, “exclusion_radius” : 3 }? again I don’t know how to use exclusion_radius


	"stonehearth:plants:berry_bush" : {
		"placement_type" : "pattern",
		"parameters" : { "min_rows" : 1, "max_rows" : 2, "min_cols" : 1, "max_cols" : 2, "item_spacing" : 4, "item_density" : 0.9 }
	},

Here it is all easy, but what the item_density will do? Is it necessary in this case? I think all the other parameters would be enough to generate the berries in a pattern.
And although I could easily check, I will ask anyway cause I’m lazy: “placement_type” : “pattern”, can be used with any item, not only berries, right? So I could spawn rocks in a row if I wanted.


"mean_offset": {
	"tree": 100,
	"water": 50,
	"boundary": 0
},

What is boundary? is the area where there is a change of terrain elevation? So if adds a very low negative value like -100 into it the item will not generate close to the edges? And how far from the edge there will be the effect?


I guess I have a few more to ask but can’t remember, that’s all for now.
Thanks for reading,

dude not to be well not helpful or anything but why not do what i did and just test out everything.
well im working on a starwars mod not a whole new biome but still give it a go.

What you mean? Test each value individually? I did that. Each value was tested around 5 times, the default, then a little less, then a lot less, maybe even negative. Then a little more than default, and last a lot more than default. Each change requires a full game restart too, which takes a lot of time… So it is hard and time consuming.

I even used a random number generator and filled the file with it just to see the chaos it would create, :joy:.

paging @Drotten, he might know how to help, or someone else who can help.

1 Like

That stuff is hard coded in lua (in stonehearth/services/server/world_generation/world_generation_service.lua at line 369, if you’re interested), and it’s set to be 1.5 blocks of distance from the top of the grass. So if you want to mess with water, look there. Though water is very much not done and buggy, so I’d recommend to not touch that or face the code’s wrath (possibly).


Could you expand on what you mean by that? Also, what values are you using to produce this error? Am I correct in assuming that you’re messing with the biome files?


The comments found in the temperate.json reads as follows:

      "__comments": {
         "valley_count": "offset of layers from base",
         "step_count": "number of layers",
         "step_size": "size of layer, for foothills and mountains this has to be multiple of 5"
      },

I couldn’t really tell you any more than that.


From the testing and searching around I came up the following response: you’d probably have to change some lua script.


I’m gonna assume you mean how to control their spawn rate.

This is done via static scenarios and can be found in json. For the rabbit statues though, I think you’d have to change the density of ruins in general (ruins is the category for the rabbit statue). You can find its value in scenarios/static/scenario_index.json. The rabbit_clan_statue.json file can be found if you search deeper within; that file has more data on the statues so you may want to look into that as well.


As far as I can tell you: it is used when calculating perturbed coordinates. What is perturbed coordinates? Google knows that better than me. :wink:


It’s necessary as it adds a random element to whether or not all the items will spawn. So an item_density of 0.9 means that, roughly, 90% of the items in the pattern will be placed.

Yes.


That’s also my guess. Anyway, the entire mean_offset block is to change the value of mean (found a bit below) depending on other variables, such as if the area we’re looking at is close to an edge/wall.

The mean value, alongside the std_dev value, is used when calculating the Gaussian function. Again, Google can tell you what it is. Just be prepared for math.


When testing out the different values without having to remake large maps over and over again. You can just add the following to your user_settings.json file:

   "mods" : {
      "stonehearth" : {
         "world_generation" : {
            "method" : "tiny"
         },
         ...
      }
   }

This will create a tiny world instead, which reduces the time it takes to simply test out your new world gen values.

3 Likes

Sometimes the game generates an area that has sunk terrain, exactly like goblin camps sunk the ground when they spawn.


:stuck_out_tongue: I love math, don’t worry. Actually, I’m messing with world generation for about 10 years now, my hd is full of little game prototypes that will never see the day light lol.

Anyway, that was actually really helpful, thanks. I will dig the lua code when I got enough free time.

Oh, aren’t those muddy areas though?

I’m trying to find where they are generated, but I’m not really having much luck so far. But if had to guess where it’s at, I’d say the code for it is in services/server/world_generation/height_map_renderer.lua at line 204, you could take a peek in there and see for yourself.

2 Likes

So, I tried changing the water level, but I didn’t get any result.
In my mod manifest I added the following:

"overrides": {
	"/stonehearth/services/server/world_generation/world_generation_service.lua": "file(services/server/world_generation/world_generation_service.lua)"
},

In the world_generation_service.lua I changed the

local water_height_delta = 1.5

at line 369 from 1.5 to 0.5 (and also tested other values) and nothing changed… :frowning:

Did I miss something?

I’m not sure, I made the same change as you did and that changed the water level as to what you would expect. The difference of what I did though, was to monkey patch that change rather than to override the file. I have no idea as to why overriding the file wouldn’t work though, so I can’t be of much help for that.

Here’s the mod that I used in order to accomplish that; go ahead and dissect it.

So, how strange is this? I thought that maybe I got some typo and that would be why it was not working, always calling the default value of 1.5 from the original file. To test I just changed the function name from my file to a random string to see if the game would fail calling a missing function.

Well, it didn’t fail, and the water level was actually 0! (same level as grass, one more drop and it would flood to land)

So, I just reverted the name back, and no matter what values or names I use now, it always get 0 for the water level…


Oh yeah, there are those random floating water tiles whenever I set shallow water to anything other than 0 or 1. I will deal with it later, or simple set it back to 0 later.

If you (or anyone else that can help) have the free time to check my files and point where I’m failing… Here are the current files from the mod
archipelago_biome.zip (34.1 KB) (I removed the images to get it lighter.)

And although I could simple copy yours, I checked it and didn’t fully understand what you did. :sweat: (StoneHearth is my first touch with lua)

I don’t have time to check it out at the moment, but I can get to it later today. For now I just wanted to help with the following.

That’s alright, I was sort of testing out your skills to see if you understood that. But let’s go over the contents in it.

The custom_world_generation_service.lua script has all the changes that we want to make, i.e. raise the water level by one voxel. As you probably noticed, it contains only a copy of one function from the original file. The first three lines are there because the function are dependent on those in order to work.

Next, in the wm_server.lua script, we are listening in on the event radiant:required_loaded. The event will be triggered once when the game starts (after all mods have been loaded into the game though). That, in turn, will call the _on_required_loaded function which will simply replace all functions within world_generation_service.lua from our own custom version of that (which is only one function at this point). For this we get both files in question, and uses the mixin function within the radiant mod (look for the function in modules/common.lua).

I hope this helps to clear up anything that you didn’t understand.

1 Like

I was going to ask how the code would know which part to replace, as the names were different, but then I realized that only the class name is different, not the function name. So you can have whatever class name, but the function name has to be the same to replace the original function, in this case the _add_water_body… Is it right?

Also, the line

local custom_world_generation_service = require('custom_world_generation_service')

is asking for the custom_world_generation_service.lua, right? I’m assuming the code is just smart and knows which file extension is there.

Those little rules that are making my progress slow… Better learn the gramar and syntax first… :stuck_out_tongue: (Googling right now, if you have a favorite source to help me learn, that would be great)

Yes. Note also that the mixin that I used only replaces/adds functions from one script to another. Variables that are declared outside of function bodies will be ignored.

Also correct. It’s important to note that the path supplied there is always relative from its mod’s base folder. E.g. if you want to grab a Lua file located in my_mod/path_to_script/script_file.lua; you’d do something like require("__path_to_script__.script_file"). So, instead of using slashes for the path, you’d use dots. Also, the parenthesis are optional, I just use them simply because I like it better with rather than without.

Another thing to note; if you want to grab a script file that’s located in a different mod, you’d use radiant.mods.require() instead. Its usage it’s the same, the difference is that the path is prefixed with the other mod’s name.


You could take a peek at their reference manual for information. If it’s not sufficient, there’s always Google to help with some of your specific questions.

1 Like