How to switch tilemaps based on a variable (ie: season_is: 'winter' , 'summer', 'spring', 'fall')

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pjallday

So i have 4 tilemap pngs all identical just different colors based on season. I want to create my level with 1 tilemap using auto tiling and then keep the exact same placement of the tiles just have those tiles switch to the appropriate season tile.

so if season = winter keep scene the exact same just use the winter tiles instead of summer tiles. Is there a more efficient way to do this besides making 4 different scenes with the only thing being different is the tilemap ?

:bust_in_silhouette: Reply From: Vadalken

Make seperate tilesets for the different seasons and save them in a folder. Then you can just change what tileset your tilemap is using. Here is some code I used to test that this works:

func _on_button_pressed():
    var new_tileset = load("res://Scenes/Maps/test_tileset2.tres")
    tile_set = new_tileset

Here I am switching from “test_tileset1” to “test_tileset2” when I press a button.

I have never done this before so there should be peculiarities and limitations I am not aware of, but it works in my toy example.