samsface / godot-steam-api

Godot Steam integration using GDNative.
400 stars 16 forks source link

[BUG] Couldn't fully load the singleton script "Steam" (possible cyclic reference or parse error) #21

Closed DotSquareGames closed 2 years ago

DotSquareGames commented 2 years ago

Describe the issue Basically, if I try to use a function with the Steam library (like, say, Steam.clear_achievement("test") for example), I have an error message saying that "Couldn't fully load the singleton script "Steam" (possible cyclic reference or parse error)". At first I did not have any message errors in the console, but now I have a few (listed below). I tried it on a copy of my current project, and for one of them it seems to work fine, but not for the other one. Weirdly enough, even in the one with all the error messages, it now seems to work (in the sense that the achievement is unlocked), even though I have a bunch of scary error messages.

Paste the code causing the issue

func _ready():
# Test steam achievements
    Steam.clear_achievement("test")
    Steam.set_achievement("test")
    print(Steam.user_stats.get_achievement_name(0))

Paste any error appearing in the console

 Resource: 'res://addons/steam_api/steam.gd' is already being loaded. Cyclic reference?
 res://addons/steam_api/steam.gd:5 - Parse Error: The identifier "Steam" isn't declared in the current scope.
 modules/gdscript/gdscript.cpp:566 - Method failed. Returning: ERR_PARSE_ERROR
 Resource: 'res://addons/steam_api/steam.gd' is already being loaded. Cyclic reference?
 res://addons/steam_api/steam.gd:5 - Parse Error: The identifier "Steam" isn't declared in the current scope.
 modules/gdscript/gdscript.cpp:566 - Method failed. Returning: ERR_PARSE_ERROR
samsface commented 2 years ago

@DotSquareGames Can you zip up a simple Godot project that reproduces the error?

DotSquareGames commented 2 years ago

Hi!There's something weird about the bug I mentioned. Basically, now it's different again: the achievements don't work anymore in the project where it used to work but had error messages. However, if I put the build into steam and launch the game from there, it works perfectly, apparently. No idea why. The game is exactly the same...So, to put it simply: it seems that I have errors or actual bug that prevent the achievement system to work properly on Godot itself, but when the build is launched from Steam, it seems (so far) to work.

I created a simple Godot project like you asked, but on this one, for some reason, it does not have any bug. I'm not sure why. But I tried again in another game of mine, and the same error happened. It seems that the error happen only on project that are not new and empty... Not sure what I can do to help you...

samsface commented 2 years ago

@DotSquareGames I really can't help unless I have a project that can reproduce your issue :shrug:

samsface commented 2 years ago

@DotSquareGames I think I see the issue. Can you try this for me?

https://github.com/samsface/godot-steam-api/blob/49dd642fa183138fb9f4ed96bbffc294d3ef9c94/addons/steam_api/steam.gd#L5

Remove 'Steam.' like this in the the file at the line linked above

-if Steam.utils.get_app_id() == godot_steam_app_id:
+if utils.get_app_id() == godot_steam_app_id:
DotSquareGames commented 2 years ago

I understand it's hard to understand what's going on without a copy of the project that has problems, but the only project that has this errors is my main commercial game, and I can't really share it.

For no reason when I opened the project that had errors, it had no errors anymore (I must say I did try to close and open it several times before, and the errors were still there back then). I did, however, try to change the line where you asked me to, and it works too. Basically both ways works fine now, no idea why (the project did not change at all), so I don't think it makes any difference. I have no idea why it did not work before, and why it does now. Same project, nothing changed as far as I'm concerned.

If the errors appears again, I'll let you know. Thank you a lot for the help, and for making this plugin in the first place (it's great)!