在作弊引擎中,我们可以使用playSound()来播放wav声音文件。我正在尝试播放摩尔斯电码的声音:
test = '.... . .-.. .-.. ---/.-- --- .-. .-.. -..'
for i= 1, #test do
chr = string.sub(test, i, i)
if chr == '.' then
playSound(findTableFile("dot.wav"))
elseif chr == '-' then
playSound(findTableFile("dash.wav"))
elseif chr == 's' then
playSound(findTableFile("shortpause.wav"))
elseif chr == ' ' then
playSound(findTableFile("mediumpause.wav"))
elseif chr == '/' then
playSound(findTableFile("longpause.wav"))
end
end但是声音只播放第一个'chr‘。如何播放所有字符'chr‘的定义的声音?
发布于 2020-02-06 10:18:12
解决问题:
test = '.... . .-.. .-.. ---/.-- --- .-. .-.. -..'
function playMorse()
for i= 1, #test do
chr = string.sub(test, i, i)
if chr == '.' then
playSound(findTableFile("dot.wav"))
sleep(300)
elseif chr == '-' then
playSound(findTableFile("dash.wav"))
sleep(300)
elseif chr == 's' then
playSound(findTableFile("shortpause.wav"))
sleep(300)
elseif chr == ' ' then
playSound(findTableFile("mediumpause.wav"))
sleep(300)
elseif chr == '/' then
playSound(findTableFile("longpause.wav"))
sleep(300)
end
end
end
playMorse()https://stackoverflow.com/questions/60086425
复制相似问题