Skip to content

Commit 32231ed

Browse files
committed
Add Variant type and type casting blocks
https://phabricator.endlessm.com/T35497
1 parent f98cdc0 commit 32231ed

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,35 @@ static func get_general_categories() -> Array[BlockCategory]:
166166

167167
var variable_category: BlockCategory = BlockCategory.new("Variables", variable_list, Color("4f975d"))
168168

169+
# Objects & Types
170+
var type_list: Array[Block] = []
171+
172+
b = BLOCKS["parameter_block"].instantiate()
173+
b.block_type = Types.BlockType.STRING
174+
b.block_format = "As String {value}"
175+
b.statement = "String({value})"
176+
type_list.append(b)
177+
178+
b = BLOCKS["parameter_block"].instantiate()
179+
b.block_type = Types.BlockType.INT
180+
b.block_format = "As int {value}"
181+
b.statement = "int({value})"
182+
type_list.append(b)
183+
184+
b = BLOCKS["parameter_block"].instantiate()
185+
b.block_type = Types.BlockType.FLOAT
186+
b.block_format = "As float {value}"
187+
b.statement = "float({value})"
188+
type_list.append(b)
189+
190+
b = BLOCKS["parameter_block"].instantiate()
191+
b.block_type = Types.BlockType.BOOL
192+
b.block_format = "As boolean {value}"
193+
b.statement = "bool({value})"
194+
type_list.append(b)
195+
196+
var type_category: BlockCategory = BlockCategory.new("Objects & Types", type_list, Color("c12f8e"))
197+
169198
# Math
170199
var math_list: Array[Block] = []
171200

@@ -256,6 +285,7 @@ static func get_general_categories() -> Array[BlockCategory]:
256285
math_category,
257286
logic_category,
258287
variable_category,
288+
type_category,
259289
input_category,
260290
sound_category,
261291
]

0 commit comments

Comments
 (0)