Replies: 5 comments 1 reply
-
I considered this kind of usage before, but found it may be more harmful than convenient. Because it's confusing if a node has an identical name with the name of the class property/method/field. And it's not strongly typed. |
Beta Was this translation helpful? Give feedback.
-
Ok it's fair, in user side I use mixing that use a property |
Beta Was this translation helpful? Give feedback.
-
Snippet looks like this: Object.defineProperty(Node.prototype, "node", {
value: new Proxy({}, { get: function (target, key) { ... } } ),
enumerable: ...
}); But there is no extension point to get it executed at a proper time (for example, at the first time the PS: |
Beta Was this translation helpful? Give feedback.
-
Types can now be modified with Write your injection code in // the registered callback will be triggered once the type `Node` loaded
require("godot.typeloader").on_type_loaded("Node", function (type) {
// static method injection
type["my_static_func"] = function () {
console.log("my_static_func_inject");
}
// instance method injection
type.prototype["my_func"] = function () {
console.log("my_func_inject", this);
}
}); |
Beta Was this translation helpful? Give feedback.
-
@G159w I've submitted a PR which introduces a statically typed Basically it automatically generates types for each scene's node hierarchy. When a scene is saved, the types update automatically. This allows you to do stuff like: In the above screenshot it's not just aware of the node hierarchy, it knows the type of each node. So it's correctly indicating an error since |
Beta Was this translation helpful? Give feedback.
-
Hello,
instead of making an immediate error of getting a missing attribute of javascript node use this.get_node("attr").
This allow to replace things like :
this.get_node("A/B/C")
or this.get_node("A").get_node("B").get_node("C")
by
this.A.B.C
Shorter code and similar to '$' syntax in GDScript.
Best regards
Beta Was this translation helpful? Give feedback.
All reactions