How do i make a world generator?

Godot Version

4.2.1

Question

The generator will be able to generate terrain and ores.
Terrain includes:

  • environment(like forest or plain)
  • rivers and lakes
  • cliffs

Ores is a set for some ores.

  • ore’s resources left
  • ore spacing
  • ore size(in world)

And all options are modifible.

There’s my base ChunkLoadSource, it will be called when world want to generates new chunk.

class_name ChunkLoadSource
extends Node

var world: World

func _load_chunk(chunk_pos: Vector2) -> Chunk:
    var chunk = world.init_chunk_for(chunk_pos);
    for x in range(Global.CHUNK_SIZE):
        for y in range(Global.CHUNK_SIZE):
            chunk.get_tile(Vector2i(x, y)).set_floor(Gindustry.floors.grass)
    return chunk;

This might be helpful to you. It can generate heights and ores, but you should be able to build your custom systems on top.