Godot: class_name overrides AutoLoad global name if using the same name

Created on 19 Apr 2019  路  1Comment  路  Source: godotengine/godot

Godot version:
3.1 official

OS/device including version:
Windows 7 PC

Issue description:
Whenever i use globals and give them a class_name, i cannot access their non-static methods via script, because the script thinks i want to access a class instead of a global, although i have autoload on. But it can be "solved" in two ways:

  • remove the class-name
  • make the func in the global static (although he seems to still try to access the Object and not the global) But here i have the advantage of not being able to emit signals from the global. Maybe more, but this is the most impactful to me.

I guess this happens only, if the class_name and the script-name are identical.

As i know this now, for me personally this is not too big of an issue, but for newcomers this could put them in front of a problem, that could be deterring them from using godot any further, as its not a direclty "logical" error, if you dont know its cause.

Steps to reproduce:

  • Add Script to autoload
  • add Class_name that is identical to the Name in Autoload
  • try executing a non-static method in the global

solve by:

  • either make method static
  • or delete class_name

Minimal reproduction project:
Reproduction_Project.zip

bug gdscript

Most helpful comment

It should likely raise an error when class_name and the AutoLoad global name conflict. There's no practical reason for using class_name in an AutoLoad (at least not with the same name), so we should just forbid it.

>All comments

It should likely raise an error when class_name and the AutoLoad global name conflict. There's no practical reason for using class_name in an AutoLoad (at least not with the same name), so we should just forbid it.

Was this page helpful?
0 / 5 - 0 ratings