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 voice = 0
|
||||
|
||||
var debug = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
var files = []
|
||||
|
@ -27,6 +29,7 @@ func _ready():
|
|||
dir.open(SFX_dir)
|
||||
dir.list_dir_begin()
|
||||
|
||||
if debug:
|
||||
print("SoundClip: ", SoundClip)
|
||||
# determine the sound group name part
|
||||
var group = SoundClip.left(SoundClip.find_last('_')).right(SoundClip.find_last('/') + 1)
|
||||
|
@ -39,7 +42,7 @@ func _ready():
|
|||
layer = ""
|
||||
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('_'))
|
||||
|
||||
if debug:
|
||||
print("group: ", group)
|
||||
print("layer: ", layer)
|
||||
|
||||
|
@ -51,19 +54,23 @@ func _ready():
|
|||
elif not file.begins_with(".") and file.begins_with(group) and file.ends_with(".wav"):
|
||||
if layer.length() == 0: # no layer specified?
|
||||
files.append(file)
|
||||
if debug:
|
||||
print("no layer specified - adding ", file)
|
||||
elif file.find(layer) > -1: # chek if the file name contains the layer string
|
||||
files.append(file)
|
||||
if debug:
|
||||
print("layer matches - adding ", file)
|
||||
|
||||
dir.list_dir_end()
|
||||
|
||||
if debug:
|
||||
print("files in list: \n", files)
|
||||
|
||||
for f in files:
|
||||
var res_file = SFX_dir + f
|
||||
var clip = load(res_file)
|
||||
clips.append(clip)
|
||||
if debug:
|
||||
print("loading ", res_file, "; result: ", clip)
|
||||
|
||||
var clip_count = clips.size()
|
||||
|
@ -86,6 +93,7 @@ func _ready():
|
|||
for i in get_children():
|
||||
voices.append(i)
|
||||
|
||||
if debug:
|
||||
print("voices: ", voices)
|
||||
|
||||
if AutoPlay:
|
||||
|
@ -100,6 +108,7 @@ sync func play():
|
|||
|
||||
voice = (voice + 1) % voices.size()
|
||||
|
||||
if debug:
|
||||
print("playing ", name, " on voice ", voice)
|
||||
|
||||
if PlayUntilEnd:
|
||||
|
@ -122,6 +131,7 @@ sync func play():
|
|||
if len(recently_played) > min_distance:
|
||||
recently_played.remove(0)
|
||||
|
||||
if debug:
|
||||
print("random pick: ", clips[i])
|
||||
|
||||
player.stream = clips[i]
|
||||
|
|
Reference in New Issue