JoeFern
JoeFern

Reputation: 117

Continue playSound() Cheat Engine Lua

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?.

Upvotes: 0

Views: 359

Answers (1)

JoeFern
JoeFern

Reputation: 117

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()

Upvotes: 0

Related Questions