Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
name: Tests
strategy:
matrix:
godot-version: [4.2.2, 4.3.0]
godot-version: [4.3.0]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("1_p83c7")
hidden = false
1 change: 1 addition & 0 deletions addons/block_code/blocks/communication/add_to_group.tres
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("2_42ixf")
hidden = false
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("1_of577")
hidden = false
1 change: 1 addition & 0 deletions addons/block_code/blocks/communication/get_node.tres
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("1_we5wl")
hidden = false
1 change: 1 addition & 0 deletions addons/block_code/blocks/communication/is_in_group.tres
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("2_o165d")
hidden = false
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("1_r4prw")
hidden = false
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("1_i50fw")
hidden = false
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("1_h3lhb")
hidden = false
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("2_7ymgi")
hidden = false
1 change: 1 addition & 0 deletions addons/block_code/blocks/input/is_input_actioned.tres
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
signal_name = ""
scope = ""
extension_script = ExtResource("2_h11b7")
hidden = false
1 change: 1 addition & 0 deletions addons/block_code/blocks/logic/compare.tres
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ defaults = {
}
signal_name = ""
scope = ""
hidden = false
1 change: 1 addition & 0 deletions addons/block_code/blocks/sounds/pause_continue_sound.tres
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ defaults = {
}
signal_name = ""
scope = ""
hidden = false
5 changes: 5 additions & 0 deletions addons/block_code/code_generation/block_definition.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const FORMAT_STRING_PATTERN = "\\[(?<out_parameter>[^\\]]+)\\]|\\{(?<in_paramete

@export var extension_script: GDScript

## If true, do not show this block in the picker. This allows a block
## definition to be kept for backwards-compatibility with existing block
## programs, but not available for use in new programs.
@export var hidden: bool = false

static var _display_template_regex := RegEx.create_from_string(FORMAT_STRING_PATTERN)


Expand Down
49 changes: 40 additions & 9 deletions addons/block_code/simple_spawner/simple_spawner.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ enum LimitBehavior { REPLACE, NO_SPAWN }

## The period of time in seconds to spawn another component. If zero, they won't spawn
## automatically. Use the "Spawn" block.
@export_range(0.0, 10.0, 0.1, "or_greater") var spawn_frequency: float = 0.0:
set = _set_spawn_fraquency
@export_range(0.0, 10.0, 0.1, "or_greater", "suffix:s") var spawn_period: float = 0.0:
set = _set_spawn_period

## How many spawned scenes are allowed. If zero, there is no limit.
@export_range(0, 50, 0.1, "or_greater") var spawn_limit: int = 50
@export_range(0, 50, 0.1, "or_greater", "suffix:scenes") var spawn_limit: int = 50

## What happens when the limit is reached and a new spawn is attempted:
## - Replace: Remove the oldest spawned scene and spawn a new one.
## - No Spawn: No spawn happens until any spawned scene is removed by other means.
@export var limit_behavior: LimitBehavior

## Old name for [member spawn_period].
##
## @deprecated: Use [member spawn_period] instead
@export_storage var spawn_frequency: float:
get:
return spawn_period
set(value):
spawn_period = value

var _timer: Timer
var _spawned_scenes: Array[Node]

Expand All @@ -53,20 +62,20 @@ func _remove_oldest_spawned():
spawned.get_parent().remove_child(spawned)


func _set_spawn_fraquency(new_frequency: float):
spawn_frequency = new_frequency
func _set_spawn_period(new_period: float):
spawn_period = new_period
if not _timer or not is_instance_valid(_timer):
return
_timer.wait_time = spawn_frequency
_timer.wait_time = spawn_period


func spawn_start():
if spawn_frequency == 0.0:
if spawn_period == 0.0:
return
if not _timer or not is_instance_valid(_timer):
_timer = Timer.new()
add_child(_timer)
_timer.wait_time = spawn_frequency
_timer.wait_time = spawn_period
_timer.timeout.connect(spawn_once)
_timer.start()
spawn_once.call_deferred()
Expand Down Expand Up @@ -107,8 +116,9 @@ func spawn_once():
spawned.position = global_position


## @deprecated: Set the [member spawn_period] property instead
func do_set_spawn_frequency(new_frequency: float):
_set_spawn_fraquency(new_frequency)
spawn_period = new_frequency


static func setup_custom_blocks():
Expand Down Expand Up @@ -159,6 +169,7 @@ static func setup_custom_blocks():
block_definition.type = Types.BlockType.STATEMENT
block_definition.display_template = "set spawn frequency to {new_frequency: FLOAT}"
block_definition.code_template = "do_set_spawn_frequency({new_frequency})"
block_definition.hidden = true
block_list.append(block_definition)

block_definition = BlockDefinition.new()
Expand All @@ -169,6 +180,26 @@ static func setup_custom_blocks():
block_definition.variant_type = TYPE_FLOAT
block_definition.display_template = "spawn frequency"
block_definition.code_template = "spawn_frequency"
block_definition.hidden = true
block_list.append(block_definition)

block_definition = BlockDefinition.new()
block_definition.name = &"simplespawner_set_spawn_period"
block_definition.target_node_class = _class_name
block_definition.category = "Lifecycle | Spawn"
block_definition.type = Types.BlockType.STATEMENT
block_definition.display_template = "set spawn period to {new_period: FLOAT}"
block_definition.code_template = "spawn_period = {new_period}"
block_list.append(block_definition)

block_definition = BlockDefinition.new()
block_definition.name = &"simplespawner_get_spawn_period"
block_definition.target_node_class = _class_name
block_definition.category = "Lifecycle | Spawn"
block_definition.type = Types.BlockType.VALUE
block_definition.variant_type = TYPE_FLOAT
block_definition.display_template = "spawn period"
block_definition.code_template = "spawn_period"
block_list.append(block_definition)

BlocksCatalog.add_custom_blocks(_class_name, block_list, [], {})
2 changes: 1 addition & 1 deletion addons/block_code/ui/picker/picker.gd
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func _update_block_components():
block_category_display.hide()

for category in block_categories:
var block_definitions := _context.block_script.get_blocks_in_category(category)
var block_definitions = _context.block_script.get_blocks_in_category(category).filter(func(block): return not block.hidden)
var order_override = CATEGORY_ORDER_OVERRIDE.get(category.name)
if order_override:
block_definitions.sort_custom(_sort_blocks_by_list_order.bind(order_override))
Expand Down
2 changes: 1 addition & 1 deletion asset-template.json.hb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Block Coding",
"description": "Create games using a high-level, block-based visual programming language.\r\n\r\nIntended as an educational tool for learners in the earlier stages of their journey towards becoming game developers. This plugin lets you create your first games with high-level blocks, avoiding the immediate need to learn to code in GDScript. Building games in this way provides a gentle introduction to programming concepts and allows you to focus your efforts on becoming familiar with the rest of the Godot Editor UI.",
"category_id": "5",
"godot_version": "4.2",
"godot_version": "4.3",
"version_string": "{{ context.release.name }}",
"cost": "MIT",
"support_level": "community",
Expand Down