Godot Version
v4.2.2.stable.official [15073afe3]
Question
Hey there! I’m trying to write a script that checks if the player has done a certain thing (by checking whether or not an autoloaded variable, called say GlobalVariable.DefeatedBoss, is set to true), and I would like to be able to reuse the script in multiple scenes, and in turn, check different autoloaded variables (such as GlobalVariable.SavedNPC or GlobalVariable.FoundLoot) depending on what the scene needs. I thought I’d do this using something like this in the script:
@export var checkedVariable: bool
...
...
if checkedVariable:
#stuff happens
And then assign the desired autoloaded variable in the inspector like you would with other exported variables when I make different scenes. This didn’t work of course, as what shows up in the inspector is just a check box indicating whether or not the variable should be set to true or false. I tried replacing “bool” with other stuff, but couldn’t think of what to use. The closest I got is this:
@export var checkedVariable: GlobalVariable
Which asked me to assign a node in the current scene for some reason.
Is it possible to do what I’m trying to do? If so, what should I put instead of “bool” to make this work? And if not, how can I make a single script check for different variables depending on the scene’s needs? Thanks in advance!