|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
Blockyheadman |
When I made a variable in a script, I made it an autoload & tried to access its contents from a different script and got this error:
Invalid get index 'game_data' (on base: 'GDScript').
Here is my autoload save script.
&& here’s my functions that all get the same error (different variable name)
|
|
|
|
Reply From: |
bepis |
When you set up the AutoLoad classes, you give them a name that you’ll use to refer to them. So you just need to prefix game_data
with whatever name you assigned it in the AutoLoad settings.
Here’s a screenshot where I create one called Globals
and one called EffectsPlayer
and in my code, to use something from Globals
for instance, I would call Globals.color = "blue"
Okay that makes sense. I did add the Save Singleton to autoload. The script is called “save.gd” && the singleton is called “Save” In my variable, which you saw, is a dictionary & I’m trying to get the dictionary value from game_data which ended up like this Save.game_data.fullscreen
or something similar. I’m just confused on why it is giving me the error to begin with. I’ve even tried getting the dictionary value like this Save.game_data["fullscreen"]
&& it gave me the same error.
Blockyheadman | 2022-06-04 16:31
You get the same error about game_data
not existing or fullscreen
?
Oddly enough, it’s working properly now. I didn’t really change anything either. that’s strange but I’ll comment here if it acts up again like that. Thanks for the help! Much appreciated!
Blockyheadman | 2022-06-04 18:08