Skip to content

Commit 95ea003

Browse files
committed
Category factory: Rename signals to methods
The rest of the blocks match the GDScript nomenclature. Except for a few "simple" or higher level abstractions. This also removes the signal manager. Keep the await for scene ready in a separate block so it can be used explicitly when needed. Add it to the Lifecycle category. Keep the category "Signal" for now as they need overhaul in ordering and colors.
1 parent 84f6682 commit 95ea003

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

addons/block_code/ui/picker/categories/category_factory.gd

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ static func get_general_blocks() -> Array[Block]:
142142
b.category = "Lifecycle"
143143
block_list.append(b)
144144

145+
b = BLOCKS["statement_block"].instantiate()
146+
b.block_format = "Await scene ready"
147+
b.statement = (
148+
"""
149+
if not get_tree().root.is_node_ready():
150+
await get_tree().root.ready
151+
"""
152+
. dedent()
153+
)
154+
b.category = "Lifecycle"
155+
block_list.append(b)
156+
145157
# Control
146158
b = BLOCKS["control_block"].instantiate()
147159
b.block_formats = ["if {condition: BOOL}"]
@@ -191,29 +203,24 @@ static func get_general_blocks() -> Array[Block]:
191203
b = BLOCKS["entry_block"].instantiate()
192204
# HACK: make signals work with new entry nodes. NIL instead of STRING type allows
193205
# plain text input for function name. Should revamp signals later
194-
b.block_format = "On signal {signal: NIL}"
195-
b.statement = "func signal_{signal}():"
206+
b.block_format = "Define method {method_name: NIL}"
207+
b.statement = "func {method_name}():"
196208
b.category = "Signal"
197209
block_list.append(b)
198210

199211
b = BLOCKS["statement_block"].instantiate()
200-
b.block_format = "Send signal {signal: STRING} to group {group: STRING}"
201-
b.statement = (
202-
"""
203-
if get_tree().root.has_node("SignalManager"):
204-
get_tree().root.get_node_or_null("SignalManager").broadcast_signal({group}, {signal})
205-
"""
206-
. dedent()
207-
)
212+
b.block_format = "Call method {method_name: STRING} in group {group: STRING}"
213+
b.statement = "get_tree().call_group({group}, {method_name})"
208214
b.category = "Signal"
209215
block_list.append(b)
210216

211217
b = BLOCKS["statement_block"].instantiate()
212-
b.block_format = "Send signal {signal: STRING} to node {node: NODE_PATH}"
218+
b.block_format = "Call method {method_name: STRING} in node {node_path: NODE_PATH}"
213219
b.statement = (
214220
"""
215-
if get_tree().root.has_node("SignalManager"):
216-
get_tree().root.get_node_or_null("SignalManager").send_signal_to_node({node}, {signal})
221+
var node = get_node({node_path})
222+
if node:
223+
node.call({method_name})
217224
"""
218225
. dedent()
219226
)

0 commit comments

Comments
 (0)