Skip to content

Conversation

@dylanmccall
Copy link
Contributor

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


func _init():
var node = preload("res://addons/block_code/simple_nodes/simple_scoring/_simple_scoring.tscn").instantiate() as Node
node.replace_by(self, true)
Copy link
Contributor

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()

Copy link
Contributor Author

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.


func _init():
var node = preload("res://addons/block_code/simple_nodes/simple_character/_simple_character.tscn").instantiate() as Node
node.replace_by(self, true)
Copy link
Contributor

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
@dylanmccall dylanmccall force-pushed the T35545-instantiate-simple-nodes branch from 065a94d to 5893a5a Compare July 17, 2024 16:44
@dylanmccall dylanmccall requested a review from starnight July 17, 2024 16:44
Comment on lines +5 to +8
func _init():
# Disable the SimpleCharacter _init function. We expect this script is
# already bound to _simple_character.tscn.
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@manuq manuq merged commit 9f6ab77 into main Jul 17, 2024
@manuq manuq deleted the T35545-instantiate-simple-nodes branch July 17, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants