Skip to content

Commit 3971f47

Browse files
committed
Port lifecycle and loops blocks
To the new block definitions. Update the resource files to match the current values when needed.
1 parent feab669 commit 3971f47

File tree

5 files changed

+25
-81
lines changed

5 files changed

+25
-81
lines changed

addons/block_code/blocks/lifecycle/physics_process.tres

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
[resource]
66
script = ExtResource("1_s0hq0")
77
name = &"physics_process"
8+
description = "Attached blocks will be executed during the \"physics\" processing step of the main loop"
9+
category = "Lifecycle"
810
type = 1
911
variant_type = 0
1012
display_template = "On Physics Process"
1113
code_template = "func _physics_process(delta):"
12-
description = "The following will be executed during the \"physics\" processing step of the main loop"
13-
category = "Lifecycle"
1414
defaults = {}
1515
signal_name = ""
16+
scope = ""

addons/block_code/blocks/lifecycle/process.tres

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
[resource]
66
script = ExtResource("1_pmina")
77
name = &"process"
8+
description = "Attached blocks will be executed during the processing step of the main loop"
9+
category = "Lifecycle"
810
type = 1
911
variant_type = 0
1012
display_template = "On Process"
1113
code_template = "func _process(delta):"
12-
description = "The following will be executed during the processing step of the main loop"
13-
category = "Lifecycle"
1414
defaults = {}
1515
signal_name = ""
16+
scope = ""

addons/block_code/blocks/loops/for.tres

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
[resource]
66
script = ExtResource("1_u01bi")
77
name = &"for"
8+
description = "Run the connected blocks [i]number[/i] times"
9+
category = "Loops"
810
type = 4
911
variant_type = 0
10-
display_template = "Repeat {n: INT}"
11-
code_template = "for __i in {n}:"
12-
description = "Run the connected blocks [i]n[/i] times"
13-
category = "Loops"
12+
display_template = "Repeat {number: INT}"
13+
code_template = "for __i in {number}:"
1414
defaults = {}
1515
signal_name = ""
16+
scope = ""

addons/block_code/blocks/loops/while.tres

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
[resource]
66
script = ExtResource("1_fxxh0")
77
name = &"while"
8+
description = "Run the connected blocks as long as [i]condition[/i] is true.
9+
10+
Hint: snap a [b]Comparison[/b] block into the condition."
11+
category = "Loops"
812
type = 4
913
variant_type = 0
1014
display_template = "While {condition: BOOL}"
1115
code_template = "while {condition}:"
12-
description = "Run the connected blocks as long as [i]condition[/i] is true.\\nHint: snap a [b]Comparison[/b] block into the condition."
13-
category = "Loops"
1416
defaults = {}
1517
signal_name = ""
18+
scope = ""

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

Lines changed: 9 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -170,60 +170,15 @@ static func get_general_blocks() -> Array[Block]:
170170
var b: Block
171171
var block_list: Array[Block] = []
172172

173-
#region Lifecycle
174-
175-
b = Util.instantiate_block(&"ready")
176-
block_list.append(b)
177-
178-
b = BLOCKS["entry_block"].instantiate()
179-
b.block_name = "process_block"
180-
b.block_format = "On Process"
181-
b.statement = "func _process(delta):"
182-
b.tooltip_text = "Attached blocks will be executed during the processing step of the main loop"
183-
b.category = "Lifecycle"
184-
block_list.append(b)
185-
186-
b = BLOCKS["entry_block"].instantiate()
187-
b.block_name = "physics_process_block"
188-
b.block_format = "On Physics Process"
189-
b.statement = "func _physics_process(delta):"
190-
b.tooltip_text = 'Attached blocks will be executed during the "physics" processing step of the main loop'
191-
b.category = "Lifecycle"
192-
block_list.append(b)
193-
194-
b = BLOCKS["statement_block"].instantiate()
195-
b.block_name = "queue_free"
196-
b.block_format = "Queue Free"
197-
b.statement = "queue_free()"
198-
b.tooltip_text = "Queues this node to be deleted at the end of the current frame"
199-
b.category = "Lifecycle"
200-
block_list.append(b)
201-
202-
#endregion
203-
#region Loops
204-
205-
b = BLOCKS["control_block"].instantiate()
206-
b.block_name = "for_loop"
207-
b.block_formats = ["repeat {number: INT}"]
208-
b.statements = ["for __i in {number}:"]
209-
b.category = "Loops"
210-
b.tooltip_text = "Run the connected blocks [i]number[/i] times"
211-
block_list.append(b)
212-
213-
b = BLOCKS["control_block"].instantiate()
214-
b.block_name = "while_loop"
215-
b.block_formats = ["while {condition: BOOL}"]
216-
b.statements = ["while {condition}:"]
217-
b.category = "Loops"
218-
b.tooltip_text = (
219-
"""
220-
Run the connected blocks as long as [i]condition[/i] is true.
173+
# Lifecycle
174+
for block_name in [&"ready", &"process", &"physics_process", &"queue_free"]:
175+
b = Util.instantiate_block(block_name)
176+
block_list.append(b)
221177

222-
Hint: snap a [b]Comparison[/b] block into the condition.
223-
"""
224-
. dedent()
225-
)
226-
block_list.append(b)
178+
# Loops
179+
for block_name in [&"for", &"while", &"break", &"continue"]:
180+
b = Util.instantiate_block(block_name)
181+
block_list.append(b)
227182

228183
b = BLOCKS["statement_block"].instantiate()
229184
b.block_name = "await_scene_ready"
@@ -238,27 +193,10 @@ static func get_general_blocks() -> Array[Block]:
238193
b.category = "Loops"
239194
block_list.append(b)
240195

241-
b = BLOCKS["statement_block"].instantiate()
242-
b.block_name = "break"
243-
b.block_format = "Break"
244-
b.statement = "break"
245-
b.category = "Loops"
246-
block_list.append(b)
247-
248-
b = BLOCKS["statement_block"].instantiate()
249-
b.block_name = "continue"
250-
b.block_format = "Continue"
251-
b.statement = "continue"
252-
b.category = "Loops"
253-
block_list.append(b)
254-
255-
#endregion
256-
#region Logs
257-
196+
# Logs
258197
b = Util.instantiate_block(&"print")
259198
block_list.append(b)
260199

261-
#endregion
262200
#region Communication
263201

264202
b = BLOCKS["entry_block"].instantiate()

0 commit comments

Comments
 (0)