0 votes

For context:
I am following a tutorial for GodotSteam: https://www.youtube.com/watch?v=si50G3S1XGU&t=722s

I'm at min 15:30 right now where we're trying to run the project without having Steam running on purpose. The expected result was to get a "failed to initialize Steam" message.

The error:
Instead, I get an error from Godot:
Invalid get index 'STEAM_NAME (on base: 'GDScript')

I made a script steamname.gd with the classname SteamMain. The script has a member variable declared as such:

extends Node
class_name SteamMain

var STEAM_NAME := "Name"

I initialized it with the value "Name" for testing purposes. I autoload steam_main.gd. I am sure this script actually loads, I made it print "test" in the ready function and I see that in the Output before the error occurs.

The error occurs here in my script lobby.gd which is attached to my Lobby scene, the current main scene of the project:

func _ready() -> void:
    steam_name_label.text = SteamMain.STEAM_NAME

steamnamelabel is just a label node in the scene:

onready var steam_name_label = $SteamNameLabel

Does anyone know why this error occurs? I'm on version v3.1.2.
(Sorry for the excessive detail in this question, better safe than sorry)

Godot version v3.1.2
in Engine by (15 points)

1 Answer

+1 vote
Best answer

Your autoload script name may be different because you are referencing autoloads not based on their class name, but based on their autoload name. In the autoload menu, make sure the name of steam_main.gd is SteamMain.

by (254 points)
selected by

That was exactly it, thank you! An alternative solution for others looking at this question: removing the class_name altogether and just using steam_main.STEAM_NAME also solves this.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.