Im trying to make some sort of terrain randomizer, and i want it to choose what the next tile is going to be by looking at what it currently is, and finding the array that contains what it can pick, then picking what the next tile is going to be. For example:
Our current plate is "Plains", it looks at its array to figure out what it can transform into, being "Swamp", "Desert" and "Plains" again, then it picks a random number (which i did figure out how to do myself) in this example lets say it picked the desert, and by the time it wants to create a new plate, it looks at the contents of the desert array and so on
i have made the randomization part and everything works just as well if you summon everything all at once without biome specific tables, but i cant figure out a way to put these biome specific tables in place. How can i do this?
The code i currently have is as follows:
func summon_loop():
var starter = ["PlateGreen"] #"PlateLime", "PlateYellow", "PlateOrange", "PlateMaroon", "PlateCyan", "PlateGray", "PlateWhite", "PlateDarkerBlue", "PlateSpico"]
var PlateGreen = ["PlateYellow"]
# i wiped many things here because it was complicating things, this needs a rewrite
# Update rewrite in progress
var plate_instance = plate.instance()
if plates_left == 0:
plate_type = rng.randi_range(0, 0) # change to 4 when debugging is done it just rolls to the only one for now
plates_left = rng.randi_range(2, 4)
# Add child, give type, increase step, subtract left plates. Simple. Update: this is old text update when code is done
add_child(plate_instance)
plate_instance.global_position.x += spawn_units * step
plate_instance.tile_set = load("res://world/plates/" + str(current[plate_type]) + ".tres")
current = current[plate_type]
print(str(current))
step += 1
plates_left -= 1
in my example the only thing it should be able to put out is "PlateYellow" but all it does is input P's, which i figured is the first letter of "PlateGreen" so this one doesnt really work out. It might be asking for alot but how can i achieve this?