Skip to content

Commit 055fce7

Browse files
committed
Don't warn when BlockCode script extends parent script
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
1 parent d6ce937 commit 055fce7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

addons/block_code/block_code_node/block_code.gd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ func _get_configuration_warnings():
8585
if get_parent() is BlockCode:
8686
warnings.append("The parent must not be a BlockCode.")
8787
if get_parent().script:
88-
warnings.append("This BlockCode will override the existing script in the parent node.")
88+
var parent_script_name: StringName = get_parent().script.get_global_name()
89+
if not (parent_script_name and block_script and parent_script_name == block_script.script_inherits):
90+
warnings.append("This BlockCode will override the existing script in the parent node.")
8991
if get_parent().find_children("*", "BlockCode", false).size() > 1:
9092
warnings.append("The parent should only contain one BlockCode.")
9193
if block_script and _get_custom_or_native_class(get_parent()) != block_script.script_inherits:

0 commit comments

Comments
 (0)