Hi, I have a question, hoping for your help. I didn't find much looking for, but maybe I missed something.
I am building the game world map and it is made up of different areas where the terrain is made of different materials (for example, areas of dirt, rock, grass, water, etc.) In practice, what I would like is that each zone is made up of its own tiles chosen randomly. Or to better explain, if I create an area of grass in building the map, for example, I want the tiles in that area to be chosen randomly from the group used for that area.
This question arises from the fact that the map I'm creating is very huge, and having to manually randomize the tiles in a certain area becomes very long. If instead there is the possibility to say for example, in that area I put a dirt zone and the tiles are randomly chosen from the group of dirt tiles, it would make the job much easier and faster. Also, since the aforementioned areas are background only (so there is no contact or interaction between the tiles and the player), every time you restart the game, the landscape changes every time.
I tried playing with gdscript, looking around. I created this script to try, and almost everything works, except it doesn't change the tile to the one chosen randomly.
for array in get_used_cells_by_id(484):
var water_0_group_tile = [484, 543, 544, 545]
var randomft = randi()%100+0
if randomft <= 40:
var randomsd = randi()%100+0
if randomsd <= 20:
var randomth = randi()%3+0
var size = get_cell_size()
var tile = Vector2(array*size, array*size)
set_cell(tile.x, tile.y, choose_tile_id[randomth])