@@ -4,6 +4,7 @@ extends CanvasLayer
44
55const CategoryFactory = preload ("res://addons/block_code/ui/picker/categories/category_factory.gd" )
66const Types = preload ("res://addons/block_code/types/types.gd" )
7+ const BlockDefinition = preload ("res://addons/block_code/code_generation/block_definition.gd" )
78
89@export var score_left : int :
910 set = _set_score_left
@@ -63,25 +64,25 @@ func set_player_score(player: String, score: int):
6364 _score_labels [player ].text = str (score )
6465
6566
66- static func get_custom_blocks () -> Array [Block ]:
67- var b : Block
68- var block_list : Array [Block ] = []
67+ static func get_custom_blocks () -> Array [BlockDefinition ]:
68+ var bd : BlockDefinition
69+ var block_definition_list : Array [BlockDefinition ] = []
6970
7071 for player in _POSITIONS_FOR_PLAYER :
71- b = CategoryFactory . BLOCKS [ "statement_block" ]. instantiate ()
72- b . block_name = "simplescoring_set_score"
73- b . block_type = Types . BlockType . STATEMENT
74- b . block_format = "Set player %s score to {score : INT} " % player
75- b . statement = "score_ %s = {score} " % _POSITIONS_FOR_PLAYER [ player ]
76- b . category = "Info | Score"
77- block_list .append (b )
78-
79- b = CategoryFactory . BLOCKS [ "statement_block" ]. instantiate ()
80- b . block_name = "simplescoring_change_score"
81- b . block_type = Types . BlockType . STATEMENT
82- b . block_format = "Change player %s score by {score : INT} " % player
83- b . statement = "score_ %s += {score} " % _POSITIONS_FOR_PLAYER [ player ]
84- b . category = "Info | Score"
85- block_list .append (b )
86-
87- return block_list
72+ bd = BlockDefinition . new ()
73+ bd . name = "simplescoring_set_score_ %s " % player
74+ bd . category = "Info | Score"
75+ bd . type = Types . BlockType . STATEMENT
76+ bd . display_template = "Set player %s score to {score: INT } " % player
77+ bd . code_template = "score_ %s = {score} " % _POSITIONS_FOR_PLAYER [ player ]
78+ block_definition_list .append (bd )
79+
80+ bd = BlockDefinition . new ()
81+ bd . name = "simplescoring_change_score_ %s " % player
82+ bd . category = "Info | Score"
83+ bd . type = Types . BlockType . STATEMENT
84+ bd . display_template = "Change player %s score by {score: INT } " % player
85+ bd . code_template = "score_ %s += {score} " % _POSITIONS_FOR_PLAYER [ player ]
86+ block_definition_list .append (bd )
87+
88+ return block_definition_list
0 commit comments