On 4.2.2. I want to set up a step on github CI to validate all gdscript in the project. There is a workaround to run --check-only on all scripts, but it fails:

SCRIPT ERROR: Compile Error: Identifier not found: Globals 
...
ERROR: Failed to load script "res://classes/example.gd" with error "Compilation failed".

It doesn't know of the autoload and fails.

So my questions are:

  • Is it possible to get my autoloads loaded before the script is compiled?
  • Is there another way to validate the scripts?

Thanks.

  • xyz replied to this.

    Bezier If you're using autoloads only for global data, it may be a better idea to use static classes instead. In my view, autoloads are kinda deprecated in 4.x

      xyz Globals contains some mutable conf variables among other things. I've understood that autoloads are the way to do this.

      • xyz replied to this.

        Bezier What is a "mutable" variable?
        With introduction of static class properties in 4.x, the autoloads became of very little use for global data storage imho.

          xyz I suppose that writing "value", or just the word "variable" alone would have better carried what I meant.

          In any case, I was not aware that variables can be static now. This was pretty well hidden from search results with outdated answers that claim the opposite showing up instead. So in case anyone else stumbles here, Static variables: https://docs.godotengine.org/en/4.2/tutorials/scripting/gdscript/gdscript_basics.html#static-variables

          With this knowledge, we can get rid of most of our autoload code immediately.

          • xyz replied to this.

            Bezier get rid of most of our autoload code immediately

            Smart choice 🙂

            Seems like it cannot find any classes.
            SCRIPT ERROR: Parse Error: Could not find type "CameraRigTP" in the current scope.
            SCRIPT ERROR: Parse Error: Identifier "AI" not declared in the current scope.