Disabled debug prints. And added a boolean to turn them on easily.
parent
2ee196b26f
commit
2a7d3fc8f6
|
@ -20,6 +20,8 @@ var ready = true # used as a semaphor for MinDelay
|
||||||
var voices = []
|
var voices = []
|
||||||
var voice = 0
|
var voice = 0
|
||||||
|
|
||||||
|
var debug = false
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
var files = []
|
var files = []
|
||||||
|
@ -27,7 +29,8 @@ func _ready():
|
||||||
dir.open(SFX_dir)
|
dir.open(SFX_dir)
|
||||||
dir.list_dir_begin()
|
dir.list_dir_begin()
|
||||||
|
|
||||||
print("SoundClip: ", SoundClip)
|
if debug:
|
||||||
|
print("SoundClip: ", SoundClip)
|
||||||
# determine the sound group name part
|
# determine the sound group name part
|
||||||
var group = SoundClip.left(SoundClip.find_last('_')).right(SoundClip.find_last('/') + 1)
|
var group = SoundClip.left(SoundClip.find_last('_')).right(SoundClip.find_last('/') + 1)
|
||||||
|
|
||||||
|
@ -39,10 +42,10 @@ func _ready():
|
||||||
layer = ""
|
layer = ""
|
||||||
else: # if the layers was specified the group will be incorrectly including the variant number, let's fix that
|
else: # if the layers was specified the group will be incorrectly including the variant number, let's fix that
|
||||||
group = group.left(group.find_last('_'))
|
group = group.left(group.find_last('_'))
|
||||||
|
if debug:
|
||||||
print("group: ", group)
|
print("group: ", group)
|
||||||
print("layer: ", layer)
|
print("layer: ", layer)
|
||||||
|
|
||||||
while true:
|
while true:
|
||||||
var file = dir.get_next()
|
var file = dir.get_next()
|
||||||
#print(file)
|
#print(file)
|
||||||
|
@ -51,20 +54,24 @@ func _ready():
|
||||||
elif not file.begins_with(".") and file.begins_with(group) and file.ends_with(".wav"):
|
elif not file.begins_with(".") and file.begins_with(group) and file.ends_with(".wav"):
|
||||||
if layer.length() == 0: # no layer specified?
|
if layer.length() == 0: # no layer specified?
|
||||||
files.append(file)
|
files.append(file)
|
||||||
print("no layer specified - adding ", file)
|
if debug:
|
||||||
|
print("no layer specified - adding ", file)
|
||||||
elif file.find(layer) > -1: # chek if the file name contains the layer string
|
elif file.find(layer) > -1: # chek if the file name contains the layer string
|
||||||
files.append(file)
|
files.append(file)
|
||||||
print("layer matches - adding ", file)
|
if debug:
|
||||||
|
print("layer matches - adding ", file)
|
||||||
|
|
||||||
dir.list_dir_end()
|
dir.list_dir_end()
|
||||||
|
|
||||||
print("files in list: \n", files)
|
if debug:
|
||||||
|
print("files in list: \n", files)
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
var res_file = SFX_dir + f
|
var res_file = SFX_dir + f
|
||||||
var clip = load(res_file)
|
var clip = load(res_file)
|
||||||
clips.append(clip)
|
clips.append(clip)
|
||||||
print("loading ", res_file, "; result: ", clip)
|
if debug:
|
||||||
|
print("loading ", res_file, "; result: ", clip)
|
||||||
|
|
||||||
var clip_count = clips.size()
|
var clip_count = clips.size()
|
||||||
|
|
||||||
|
@ -86,7 +93,8 @@ func _ready():
|
||||||
for i in get_children():
|
for i in get_children():
|
||||||
voices.append(i)
|
voices.append(i)
|
||||||
|
|
||||||
print("voices: ", voices)
|
if debug:
|
||||||
|
print("voices: ", voices)
|
||||||
|
|
||||||
if AutoPlay:
|
if AutoPlay:
|
||||||
play()
|
play()
|
||||||
|
@ -100,7 +108,8 @@ sync func play():
|
||||||
|
|
||||||
voice = (voice + 1) % voices.size()
|
voice = (voice + 1) % voices.size()
|
||||||
|
|
||||||
print("playing ", name, " on voice ", voice)
|
if debug:
|
||||||
|
print("playing ", name, " on voice ", voice)
|
||||||
|
|
||||||
if PlayUntilEnd:
|
if PlayUntilEnd:
|
||||||
if player.playing:
|
if player.playing:
|
||||||
|
@ -122,7 +131,8 @@ sync func play():
|
||||||
if len(recently_played) > min_distance:
|
if len(recently_played) > min_distance:
|
||||||
recently_played.remove(0)
|
recently_played.remove(0)
|
||||||
|
|
||||||
print("random pick: ", clips[i])
|
if debug:
|
||||||
|
print("random pick: ", clips[i])
|
||||||
|
|
||||||
player.stream = clips[i]
|
player.stream = clips[i]
|
||||||
|
|
||||||
|
|
Reference in New Issue