8000 Port logic blocks · endlessm/godot-block-coding@db6ac46 · GitHub
[go: up one dir, main page]

Skip to content

Commit db6ac46

Browse files
manuqwnbaum
andcommitted
Port logic blocks
And add missing defaults to the compare resource file. Co-authored-by: Will Baumgartner <wnb@endlessos.org>
1 parent df5ff19 commit db6ac46

File tree

2 files changed

+5
-45
lines changed

2 files changed

+5
-45
lines changed

addons/block_code/blocks/logic/compare.tres

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ variant_type = 1
1818
display_template = "{float1: FLOAT} {op: OPTION} {float2: FLOAT}"
1919
code_template = "{float1} {op} {float2}"
2020
defaults = {
21+
"float1": 1.0,
22+
"float2": 1.0,
2123
"op": SubResource("Resource_ie4sg")
2224
}
2325
signal_name = ""

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

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -202,53 +202,11 @@ static func get_general_blocks() -> Array[Block]:
202202
b = Util.instantiate_block(block_name)
203203
block_list.append(b)
204204

205-
#region Logic
206-
207-
b = BLOCKS["control_block"].instantiate()
208-
b.block_name = "if"
209-
b.block_formats = ["if {condition: BOOL}"]
210-
b.statements = ["if {condition}:"]
211-
b.category = "Logic | Conditionals"
212-
block_list.append(b)
213-
214-
b = BLOCKS["control_block"].instantiate()
215-
b.block_name = "if_else"
216-
b.block_formats = ["if {condition: BOOL}", "else"]
217-
b.statements = ["if {condition}:", "else:"]
218-
b.category = "Logic | Conditionals"
219-
block_list.append(b)
220-
221-
b = BLOCKS["parameter_block"].instantiate()
222-
b.block_name = "compare_int"
223-
b.variant_type = TYPE_BOOL
224-
b.block_format = "{int1: INT} {op: OPTION} {int2: INT}"
225-
b.statement = "({int1} {op} {int2})"
226-
b.defaults = {
227-
"op": OptionData.new(["==", ">", "<", ">=", "<=", "!="]),
228-
"int1": "1",
229-
"int2": "1",
230-
}
231-
b.category = "Logic | Comparison"
232-
block_list.append(b)
233-
234-
for op in ["and", "or"]:
235-
b = BLOCKS["parameter_block"].instantiate()
236-
b.block_name = op
237-
b.variant_type = TYPE_BOOL
238-
b.block_format = "{bool1: BOOL} %s {bool2: BOOL}" % op
239-
b.statement = "({bool1} %s {bool2})" % op
240-
b.category = "Logic | Boolean"
205+
# Logic
206+
for block_name in [&"if", &"else_if", &"else", &"compare", &"and", &"or", &"not"]:
207+
b = Util.instantiate_block(block_name)
241208
block_list.append(b)
242209

243-
b = BLOCKS["parameter_block"].instantiate()
244-
b.block_name = "not"
245-
b.variant_type = TYPE_BOOL
246-
b.block_format = "Not {bool: BOOL}"
247-
b.statement = "(not {bool})"
248-
b.category = "Logic | Boolean"
249-
block_list.append(b)
250-
251-
#endregion
252210
#region Input
253211

254212
block_list.append_array(_get_input_blocks())

0 commit comments

Comments
 (0)
0