Changing Biome/Terrain generator

There is two ways to generate the trees. One of them are from another random map generator, but instead of generating elevations for the terrain, it generates the vegetation sizes. That’s that part in the code where you select the sizes of trees based on a score (0 and up for small, 10 and up for medium, 18 and up for large, etc…).

The other way is like any other object, randomly placed around. Deserts do this with trees, while temperate do both.

But there is also some hard coded things in Lua, like berries can’t generate on mountains, there is a specific line I just saw that checks for it, if terrain = mountain (or plains holes), don’t generate berries, lol :stuck_out_tongue: No idea why limit it in Lua though.

3 Likes

Setting Valley Count to 2 is throwing up errors for me, can you link me to an exception?

What was the error?

Oh, and there is another way to hide it, simple by coloring it the same color as grass.

     "dirt": "#8BB270",
     "dirt_edge_1": "#8BB270",

It was an error with Line 228 in the biome lua (looking into it now). In the mean time I’ve just been using the 1 1 1 with the recolor as you described

Edit: That error seemed to be caused by a bad base height. The new error is line 400 in the landscaper

I wasn’t sure if I needed to add a dirt_edge_2: but doing so created this abomination
https://i.gyazo.com/cf5570432b0bbb1e53075f252e7460ea.png

Yes, the base height must be a multiple of 5 in this math:

(step_size * step_count) + height_base

( 1 * 1 ) + 39 = 40, is ok
or
( 2 * 2 ) + 36 = 40, is also ok

Line 400 is about tree placement, did you change something else?

There is no dirt_edge_2 as far as I remember. Can’t see your image.

Yeah I fixed the height, but still got the landscaper error. I’ve decided to just stick with Step Count 2 for the time being, since the dirt patches are so infrequent. But if you manage to make a file that has a valley count of 2 (so not requiring a recolor fix) let me know. The other issue I was having with the recolor fix was that I simply couldn’t get berries to ever spawn in plains (because they were being treated as dirt).

For berries to spawn at plains 1 (dirt) remove this:

   if terrain_type == 'plains' and step == 1 then
      return false
   end

from landscaper.lua at line 529

How is your plains setting? I got the fix using this:

  "height_base": 36,
  "plains": {
     "step_size": 2,
     "valley_count": 2,
     "step_count": 2
  },

Was that plains setting preventing dirt patches from appearing?

From a quick test yes, I tested around 10 seeds and none had them and no errors when embarking. Maybe it was just luck? I still didn’t got this valley_count figured out.

1 Like

From what I can extract from the biome lua, it seems like setting the valley count to 2 makes the height_valley equal to the height_max (normally 2 lower)?

(lines 228-230)
assert(terrain_info.plains.height_max % slice_size == 0)
terrain_info.height_min = terrain_info.plains.height_valley
terrain_info.height_max = terrain_info.mountains.height_max

So who knows why, but at least it works haha

Everything was written in Lua prior to Rayya’s Children release. With that, they introduced the JSON model. So desert generation uses the latest Radiant-preferred way to generate the biome (via JSON), while the temperate model has not yet been updated thoroughly and is using some old sections of code that they didn’t replace for whatever reason.

2 Likes