Closed ondrejhonus closed 3 months ago
I'm using toPlainScientific to convert the number to string format.
Save: coins.toPlainScientific() Load: Big.new(coins_string_from_file)
Well the problem was that the get_as_text() function was reading the values wrong and not how I wanted to, but now I tried to use the store_line() and get_line() function and it's working perfectly how i imagined it to work. Thank you for trying to help me, I really do appreciate it.
If anyone cares to see the code then here you are lol:
func save_score() -> void:
var file: FileAccess = FileAccess.open(SAVE_DIR, FileAccess.ModeFlags.WRITE)
file.store_line(coins.toString())
file.store_line(cps.toString())
file.store_line(click_power.toString())
file.store_line(cursor_price.toString())
file.store_32(playtime_seconds)
file.close()
print("Score saved successfully")
pass
func load_score() -> void:
if FileAccess.file_exists(SAVE_DIR):
var file: FileAccess = FileAccess.open(SAVE_DIR, FileAccess.ModeFlags.READ)
coins = Big.new(file.get_line())
cps = Big.new(file.get_line())
click_power = Big.new(file.get_line())
cursor_price = Big.new(file.get_line())
playtime_seconds = file.get_32()
file.close()
print("Score loaded successfully: ", playtime_seconds)
print("coins: ", coins)
else:
print("Save file not found")
resolved
I am trying to make a clicker game and i need to have saves. The way I intended of saving the numbers is as shown below, but I can't find a way to convert a string to a Big number, does anyone have a solution to my problem?
This is what i came up with, but it doesn't work: