extends AudioStreamPlayer @export var ambient: Array[AudioStream] @export var songs: Array[AudioStream] # How many more until a song is played? var song = 1 # Called when the node enters the scene tree for the first time. func _ready(): randomize() ambient.shuffle() songs.shuffle() # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta): # Get the next song if !playing: var new_song # Play a song or a ambient! if song == 0: # Next one won't be a song! song = randi_range(1, 3) songs.push_back(songs[0]) new_song = songs.pop_front() else: ambient.push_back(ambient[0]) new_song = ambient.pop_front() song -= 1 stream = new_song print("Playing: " + new_song.resource_path.get_file().get_basename()) play()