Welcome to the forums @obsessedthinking!
I think you can achieve this using Godot's build in random number generator. To randomize the language and quest order, you could try using the shuffle function. To keep certain quests in the same order, the simplest way would probably be to store the quests in several arrays initially, and combine them after randomizing the ones you want. Finally, you can you save files (documentation) to detect if the language and quest arrays have been generated already, and if they have, just load the files instead of generating them.
Here's some untested code for how it could potentially be accomplished:
const SAVE_FILE_LOCATION = "user://save_file.txt"
# I don't know what the data you have will look like, so I'm just going to use
# simple strings.
var language_array = ["a", "b", "c"]
var important_quests_1 = ["Tutorial", "Quest_01"]
var random_quests_1 = ["Quest_02", "Quest_03", "Quest_04"]
var important_quests_2 = ["Tutorial_02"]
var random_quests_2 = ["Quest_05", "Quest_06"]
# a dictionary to hold data we want to save/load
var game_data_dictionary = {}
func _ready():
# check for a save file
var save_game_file = File.new()
if (save_game_file.file_exists(SAVE_FILE_LOCATION)):
load_game_data(save_game_file)
else:
generate_game_data(save_game_file)
save_game_data(save_game_file)
func load_game_data(game_file):
game_file.open(SAVE_FILE_LOCATION, File.READ)
game_data_dictionary = parse_json(game_file.get_line())
game_file.close()
# Done! Now we can use save_game_dictionary as needed
print (game_data_dictionary)
print ("")
print ("Language array: ", game_data_dictionary["language_array"])
func generate_game_data():
# Get a new random seed for the random number generator
randomize()
# Randomize the language array
language_array.shuffle()
# Shuffle the random quests
random_quests_1.shuffle()
random_quests_2.shuffle()
# Add the random language to the save game dictionary
game_data_dictionary["language_array"] = language_array
# You can either save all of the arrays individually, or combine them
# in this example, I'll just combine them so it's a single value in the dictionary.
game_data_dictionary["quests_array"] = important_quests_1 + random_quests_1 + important_quests_2 + random_quests_2
func save_game_data(game_file):
# Save to a file
game_file.open(SAVE_FILE_LOCATION, File.WRITE)
game_file.store_line(to_json(game_data_dictionary))
game_file.close()
That's more or less the approach I'd take if I was going at this problem, though because the code isn't tested, I'm not sure if it will work or not.
This discussion was caught in the moderation queue since you have not confirmed your account yet.
Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.
If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile: