S_S
January 27, 2025, 7:16pm
1
Godot Version
4.3
Question
Help, please. I can’t figure out what could be causing this strange behavior. I can see in the debugger that it’s 1. But comparing int to int gives null. If I access property via get, the comparison works correctly. I’ve been struggling for half a day, I couldn’t figure out what is wrong. (
print(myobject.myvalue) # 1
print(myobject.myvalue ==1) # null print(myobject.get(“myvalue”)==1) # true
What is myobject
, and what is myvalue
exactly? You probably have to show more code.
2 Likes
S_S
January 27, 2025, 9:49pm
3
This is my class that inherits Node. Part of a state machine.
But the way I implemented it, I have classes referencing each other. Maybe that’s the point? I’ve read here that it’s not recommended to do that in Godot:
opened 10:23PM - 17 Mar 20 UTC
closed 10:56PM - 17 Mar 20 UTC
archived
topic:gdscript
**Describe the project you are working on:**
Nuclear Reactor control room simul… ation
**Describe the problem or limitation you are having in your project:**
I would love to be able to use static typing throughout my project, but currently I run into several issues that prevent me from doing it very widely.
One major issue is that classes can not reference each other, even transitively. This leads to cyclical reference errors very often, and some times, due to the transitive nature of it, in unexpected cases.
The end result is I often have to just remove the static typing.
**Describe the feature / enhancement and how it helps to overcome the problem or limitation:**
I recognize that this would probably end up being a pretty big task.
GDScript would probably need to implement some sort of multi-pass complication. First scan every script file collecting public symbols (_member variables and functions_). Then run a second pass where method bodies are actually evaluated, this time with full knowledge of all of the accessible symbols.
**Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:**
In the end it would allow for something even as tightly coupled as this:
```GDScript
##########################
# ClassA.gd
extends Node
class_name ClassA
var classB: ClassB
func a_method(classB: ClassB):
classB.b_method(self)
##########################
# ClassB.gd
extends Node
class_name ClassB
var classA: ClassA
func b_method(classA: ClassA):
classA.a_method(self)
```
The above is an extreme example, and let me stop you right there, yes it's obviously bad code. However if the type system is robust enough to support that worst case scenerio, then it can support anything we might need to do with it.
**If this enhancement will not be used often, can it be worked around with a few lines of script?:**
I think it would be used quite often!
However, the work around is just to not use static typing sadly.
**Is there a reason why this should be core and not an add-on in the asset library?:**
It's fundamental to how GDScript parses scripts, it can't be implemented externally.
wchc
January 27, 2025, 11:09pm
4
Share the code of your class please.
2 Likes
S_S
January 28, 2025, 11:10am
5
Thanks everyone. I started rewriting the entire structure and at the same time decided to look at all the warnings in the debugger.
And I saw a message about an error calling a non static method, which does not interrupt the process and does not critically affect anything in the logic.
After that, the links break.
static var anim_queue_started: bool:
get = _get_anim_queue_started
func _get_anim_queue_started() → bool:
return Game.GameBoard._animation_is_queuing