Godot Version
Godot 4.6.2
Question
I'm getting this error and no matter what I try I just can't seem to fix it. Basically I used this tutorial for saving and loading:https://www.youtube.com/watch?v=lXO5Jt957BA&t=308s. And when I applied it in a Global script it worked, but then for this one variable it didn’t, Below is the Global script:
extends Node
var speed = 2000
var save_path = "user://variable.save"
var RaidenRacewayTime := 0
var RaidenRacewayEndingTime := 0
var SakuraSpeedwayTime := 0
var SakuraSpeedwayEndingTime := 0
var KyotoCircuitTime := 0
var KyotoCircuitEndingTime := 0
var DaimyoDragTime := 0
var DaimyoDragEndingTime := 0
var MtFujiTime := 0
var MtFujiEndingTime := 0
const RaidenAT = 11.579
const SakuraAT = 18.179
const KyotoAT = 8.989
const DaimyoAT = 19.939
const FujiAT = 49.489
const RaidenGold = 13
const SakuraGold = 19
const KyotoGold = 10
const DaimyoGold = 21
const FujiGold = 50
const RaidenSilver = 15
const SakuraSilver = 20
const KyotoSilver = 12
const DaimyoSilver = 23
const FujiSilver = 51
const RaidenBronze = 20
const SakuraBronze = 23
const KyotoBronze = 15
const DaimyoBronze = 30
const FujiBronze = 55
var isRaidenATGet = false
var isSakuraATGet = false
var isKyotoATGet = false
var isDaimyoATGet = false
var isMtFujiATGet = false
var isAllATGet = false
func _process(delta: float) -> void:
if isRaidenATGet == true and isSakuraATGet == true and isKyotoATGet == true and isDaimyoATGet == true:
isAllATGet = true
func save():
var file = FileAccess.open(save_path, FileAccess.WRITE)
file.store_var(RaidenRacewayEndingTime)
file.store_var(SakuraSpeedwayEndingTime)
file.store_var(KyotoCircuitEndingTime)
file.store_var(DaimyoDragEndingTime)
file.store_var(MtFujiEndingTime)
func load_data():
if FileAccess.file_exists(save_path):
var file = FileAccess.open(save_path, FileAccess.READ)
RaidenRacewayEndingTime = file.get_var(RaidenRacewayEndingTime)
SakuraSpeedwayEndingTime = file.get_var(SakuraSpeedwayEndingTime)
KyotoCircuitEndingTime = file.get_var(KyotoCircuitEndingTime)
DaimyoDragEndingTime = file.get_var(DaimyoDragEndingTime)
MtFujiEndingTime = file.get_var(MtFujiEndingTime)
else:
print("no data has been saved")
DaimyoDragEndingTime = 0
RaidenRacewayEndingTime = 0
SakuraSpeedwayEndingTime = 0
KyotoCircuitEndingTime = 0
MtFujiEndingTime = 0
And then this is the script with the save and load button:
extends CanvasLayer
func _ready() -> void:
hide()
func _on_save_data_pressed() -> void:
Global.save()
func _on_load_data_pressed() -> void:
Global.load_data()
func _on_exit_pressed() -> void:
hide()
func _on_setting_pressed() -> void:
show()
Any help would be greatly appreciated.