IssueRaiser

Implement `onready` setters

<!-- Please fill in *all* the questions below and don't remove any of them. Proposals not following the template below will be closed immediately. --> **Describe the project you are working on:** Game with "interactive" nodes, which use tool script with setters and stuff. **Describe the problem or limitation you are having in your project:** Real use case here. I have a node called Door. It has two exported properties with setters: `right` and `texture`. When you set `right` to true, the sprite gets flipped, but there's also a collider that changes position to opposite side. `texture` is a... well, sprite texture. The Door script is a tool script. I recently noticed that I can't just use `_process()` in every tool script that reacts to variable changes, because it kills my GPU due to constant scene redrawing. So I switched to setters and ran into another problem. As you might guess from above description, my tool script affects two underlying nodes by editing their properties. The problem is initialization. When I run the game, the setters are called instantly and error out, because they rely on using `get_node()` before the children are initialized. Right now I'm using a workaround where in the setter I check if the node is inside tree and `return` if not and also inside `_ready()` I call the setters directly _with current value_ to initialize them properly. tbh it feels like a hack and also I will have to do this for every "interactive" object, which is meh. Related iss

Posted by KoBeWi on Dec 20, 2019, 5:48 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

github (Other)

Implement `onready` setters

KoBeWiDec 20, 2019, 5:48 PM

<!-- Please fill in *all* the questions below and don't remove any of them. Proposals not following the template below will be closed immediately. --> **Describe the project you are working on:** Game with "interactive" nodes, which use tool script with setters and stuff. **Describe the problem or limitation you are having in your project:** Real use case here. I have a node called Door. It has two exported properties with setters: `right` and `texture`. When you set `right` to true, the sprite gets flipped, but there's also a collider that changes position to opposite side. `texture` is a... well, sprite texture. The Door script is a tool script. I recently noticed that I can't just use `_process()` in every tool script that reacts to variable changes, because it kills my GPU due to constant scene redrawing. So I switched to setters and ran into another problem. As you might guess from above description, my tool script affects two underlying nodes by editing their properties. The problem is initialization. When I run the game, the setters are called instantly and error out, because they rely on using `get_node()` before the children are initialized. Right now I'm using a workaround where in the setter I check if the node is inside tree and `return` if not and also inside `_ready()` I call the setters directly _with current value_ to initialize them properly. tbh it feels like a hack and also I will have to do this for every "interactive" object, which is meh. Related iss

Comments (0)

No comments yet. Start the discussion.

Comment on this issue