Godot 4 · GDScript
Inventory sounds without immediate repeats
Open a pouch once and you hear canvas shift. Open it ten times and you start to recognize the recording. Give the action a few takes and let the player remember which one it just played.
Hear the selection rule
Download the demo ZIP from the v1.0.0 release. Extract it, import project.godot in Godot and press F5 to run the sound shelf.
Press 1 through 6 to hear each sound on its own. Then tap R a few times. The shelf picks from the same six sounds and shows which one you heard. Each pick excludes the previous sound.
Wire up an inventory button
In the demo project, create a new scene with a Button as its root. Attach a GDScript to the button and replace its contents with the example below.
extends Button
const POUCH := preload("res://demo/audio/Cloth/PC_17_canvas_pouch_open_A.wav")
const PAGE := preload("res://demo/audio/Paper/PC_05_ledger_page_turn_A.wav")
var foley := PocketCounterPlayer.new()
func _ready() -> void:
var gesture := PocketCounterGesture.new()
gesture.id = &"inventory_move"
gesture.takes.assign([POUCH, PAGE])
foley.gestures.append(gesture)
add_child(foley)
text = "Move item"
pressed.connect(play_inventory_move)
func play_inventory_move() -> void:
foley.play_gesture(&"inventory_move")
Save the scene, press F6 to run it and click Move item a few times. You’ll hear a canvas pouch opening and a ledger page turning on alternate clicks. The example pairs two different free sounds so you can hear the choice clearly.
Choose takes for each action
For a page turn in your own game, record two or three different page turns and put those streams under the same gesture ID. On each call the player excludes that gesture’s last stream and randomly picks from the other distinct streams. Empty slots and duplicate references add no choices.
Two takes always alternate. With three, a sequence such as A → B → A is possible. A single take plays on every trigger. Each gesture remembers its own last stream, so counting coins between two page turns preserves the page-turn history.
To use the player outside the demo, unzip the add-on ZIP from the same release into your project root. Keep your WAVs under res:// and update the paths in the example.