Skip to content

Commit

Permalink
Add simple sound node
Browse files Browse the repository at this point in the history
  • Loading branch information
starnight committed Jun 17, 2024
1 parent 38e7406 commit 51cd4d8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions addons/block_code/simple_nodes/simple_sound/simple_sound.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@tool
class_name SimpleSound
extends AudioStreamPlayer


func get_class():
return "SimpleSound"


static func get_custom_blocks() -> Array[BlockCategory]:
var b: Block

# Play the sound
var sound_list: Array[Block] = []
b = CategoryFactory.BLOCKS["statement_block"].instantiate()
b.block_type = Types.BlockType.EXECUTE
b.block_format = "Play the sound with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"
b.statement = "volume_db={db}\npitch_scale={pitch}\n" + "play()"
sound_list.append(b)

var sound_cat: BlockCategory = BlockCategory.new("PlaySound", sound_list, Color("e30fc0"))

return [sound_cat]
6 changes: 6 additions & 0 deletions addons/block_code/simple_nodes/simple_sound/simple_sound.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dnea31ja51r43"]

[ext_resource type="Script" path="res://addons/block_code/simple_nodes/simple_sound/simple_sound.gd" id="1_7dbg7"]

[node name="SimpleSound" type="AudioStreamPlayer"]
script = ExtResource("1_7dbg7")

0 comments on commit 51cd4d8

Please sign in to comment.