Skip to content

Don't warn when BlockCode script extends parent script #370

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

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

wjt
Copy link
Member

@wjt wjt commented Jan 29, 2025

Commit 87c31b0 ("Warn when Block Code overrides parent script") introduced a warning when a BlockCode node's parent has a script attached. But if the parent is (for example) a Character2D with our SimpleCharacter script attached, this warning is incorrect: the block code script will correctly extend, not override, the parent.

Before issuing this warning, check if the parent's script has a class_name that matches what the generated BlockCode script will extend, and suppress the warning if so.

Fixes #356

@wjt wjt requested a review from manuq January 29, 2025 11:56
@wjt
Copy link
Member Author

wjt commented Jan 29, 2025

I made a test scene with the 4 cases:

  1. BlockCode attached to SimpleCharacter
  2. BlockCode attached to node with custom script with a class_name that the block code plugin doesn't know about
  3. BlockCode attached to node with custom script with no class_name
  4. BlockCode attached to node with no script

Before:

image

After:

image

Commit 87c31b0 ("Warn when Block Code
overrides parent script") introduced a warning when a BlockCode node's
parent has a script attached. But if the parent is (for example) a
Character2D with our SimpleCharacter script attached, this warning is
incorrect: the block code script will correctly extend, not override,
the parent.

Before issuing this warning, check if the parent's script has a
class_name that matches what the generated BlockCode script will extend,
and suppress the warning if so.

Fixes #356
@wjt wjt force-pushed the push-msnptorpnqrl branch from 13caf74 to 055fce7 Compare January 29, 2025 11:58
@@ -85,7 +85,9 @@ func _get_configuration_warnings():
if get_parent() is BlockCode:
warnings.append("The parent must not be a BlockCode.")
if get_parent().script:
warnings.append("This BlockCode will override the existing script in the parent node.")
var parent_script_name: StringName = get_parent().script.get_global_name()
if not (parent_script_name and block_script and parent_script_name == block_script.script_inherits):
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 18c8de5 into main Jan 29, 2025
3 checks passed
@manuq manuq deleted the push-msnptorpnqrl branch January 29, 2025 12:26
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.

A CodeBlock should not be allowed to attach to a node that has a script attached already
2 participants