0

In Cheat Engine, to play a wav sound file we can use playSound(). I am trying to play sound for Morse code:

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

But sound playing only the first 'chr'. How to play all characters 'chr' by their defined sound?.

JoeFern
  • 117
  • 1
  • 8
  • Something strange, I try to run the code again and it works play all this sound. So, I just need to add delay time about a half-second between each character sounds because of sound played too fast. How I can do that?. Using a timer? How? – JoeFern Feb 06 '20 at 02:09

1 Answers1

0

Problem-solve:

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()
JoeFern
  • 117
  • 1
  • 8