Skip to content

Commit 78e9390

Browse files
wnbaumwjt
authored andcommitted
Fixe base class identification
For previous classes with custom blocks, like SimpleCharacter, you had to define a method that specified the base class so the picker would know which blocks to populate itself with. However, there is a function script.get_instance_base_type() that gets this automatically from whichever class the script extends. Much nicer than having to define a function for this every time. This change also fixes an error when opening the pong game.
1 parent 5747614 commit 78e9390

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

addons/block_code/simple_nodes/simple_character/simple_character.gd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ func get_custom_class():
1313
return "SimpleCharacter"
1414

1515

16-
static func get_base_class():
17-
return "CharacterBody2D"
18-
19-
2016
static func get_exposed_properties() -> Array[String]:
2117
return ["position"]
2218

addons/block_code/ui/picker/picker.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func bsd_selected(bsd: BlockScriptData):
2525

2626
var parent_class: String
2727
if found_simple_class_script:
28-
parent_class = found_simple_class_script.get_base_class()
28+
parent_class = str(found_simple_class_script.get_instance_base_type())
2929
else: # Built in
3030
parent_class = bsd.script_inherits
3131

0 commit comments

Comments
 (0)