-
Notifications
You must be signed in to change notification settings - Fork 27
Change Simple node scripts to instantiate themselves #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -19,6 +19,13 @@ const _POSITIONS_FOR_PLAYER = { | |||
} | |||
|
|||
|
|||
func _init(): | |||
var node = preload("res://addons/block_code/simple_nodes/simple_scoring/_simple_scoring.tscn").instantiate() as Node | |||
node.replace_by(self, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I play the Pong game, it shows error:
E 0:00:00:0452 simple_scoring.gd:24 @ _init(): Condition "p_node->data.parent" is true.
<C++ Source> scene/main/node.cpp:2796 @ replace_by()
<Stack Trace> simple_scoring.gd:24 @ _init()
block_code.gd:56 @ _update_parent_script()
block_code.gd:14 @ _ready()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, I see how that happened. That's fixed in the newest set of commits.
@@ -52,6 +52,13 @@ func on_gravity_changed(new_gravity): | |||
gravity = new_gravity | |||
|
|||
|
|||
func _init(): | |||
var node = preload("res://addons/block_code/simple_nodes/simple_character/_simple_character.tscn").instantiate() as Node | |||
node.replace_by(self, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I play the Pong game, it shows error:
E 0:00:00:0445 simple_character.gd:57 @ _init(): Condition "p_node->data.parent" is true.
<C++ Source> scene/main/node.cpp:2796 @ replace_by()
<Stack Trace> simple_character.gd:57 @ _init()
block_code.gd:56 @ _update_parent_script()
block_code.gd:14 @ _ready()
To support users adding SimpleCharacter and SimpleScoring as nodes, instead of as child scenes, add an _init function for each which loads the appropriate scene file and instantiates it. https://phabricator.endlessm.com/T35545
065a94d
to
5893a5a
Compare
func _init(): | ||
# Disable the SimpleCharacter _init function. We expect this script is | ||
# already bound to _simple_character.tscn. | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
To support users adding SimpleCharacter and SimpleScoring as nodes, instead of as child scenes, add an _init function for each which loads the appropriate scene file and instantiates it.
https://phabricator.endlessm.com/T35545