Replies: 3 comments 2 replies
-
First of all, vertically decompressing your code is good in most cases, as it is usually more readable, harder to lose your place when reading, and ideally all optimized out anyways. Secondly, this is more an issue of programming habit. GDScript is dynamically typed, so if you want static typed external access, you should use getters and setters. This tells Godot that it's a function that should only accept a variable containing a string (which is known at runtime) and not to expect anything back in return. Although realistically, GDScript shouldn't really care what you're assigning to what, so I don't know why that would error. You can assign a string to an int and vice versa, so idk what the issue is there. |
Beta Was this translation helpful? Give feedback.
-
Any reason why disabling the warning Addendum: Consider that in the proposed solution |
Beta Was this translation helpful? Give feedback.
-
You can use type casting |
Beta Was this translation helpful? Give feedback.
-
not a trained programmer
To make my code more readable, i try to use single lines to set properties of UI nodes.
Unfortunately these can not be typed in the same single line. Creating new variables every time would extend my code vertically and thus reduce readability.
Current code examples:
result: "The property "text" is not present on the inferred type "Node" (but may be present on a subtype). UNSAFE_PROPERTY_ACCESS"
Proposal:
Beta Was this translation helpful? Give feedback.
All reactions