Skip to content

Commit 808cec9

Browse files
Bug: Clean Scren in windows
1 parent 7fbdbb9 commit 808cec9

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

forca.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function main()
77
Forca = Game:new() -- Instancia Objeto
88
continua = "S"
99
while(continua == "S" or continua == "s") do
10-
os.execute("clear") -- Limpa tela
10+
ForcaGame:Clear()
1111
print("-------------------------------------")
1212
print(" FORCA LUA ")
1313
print("-------------------------------------")

game.lua

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ end
1717

1818
function ForcaGame:Start(mode)
1919
ForcaGame:Reiniciar() -- Reinicia Variaveis
20-
os.execute("clear") -- Limpa tela
20+
ForcaGame:Clear()
2121
str = ""
2222
if mode == 1 then
2323
io.read()
@@ -37,7 +37,7 @@ function ForcaGame:Start(mode)
3737

3838
io.read()
3939

40-
os.execute("clear") -- Limpa tela
40+
ForcaGame:Clear()
4141
ForcaGame.dica = string.upper( ForcaGame.dica ) -- Coloca dica em caixa alta
4242
ForcaGame:InicializaPalavra(str) -- Remove espacos e inicializa WORD
4343

@@ -66,7 +66,7 @@ function ForcaGame:Start(mode)
6666
io.write("Digite uma Letra: ")
6767
ForcaGame.letra = string.upper( io.read() ) -- Coloca letra maiuscula
6868
ForcaGame:VerificaLetra(ForcaGame.letra) -- Verifica se a letra esta na palavra
69-
os.execute("clear") -- Limpa tela
69+
ForcaGame:Clear()
7070
else
7171
print("Voce Perdeu!!! Palavra Correta: " .. str)
7272
break
@@ -90,7 +90,9 @@ function ForcaGame:Reiniciar() -- Reinicia variaveis do objeto
9090
end
9191

9292
function ForcaGame:SorteiaDica() -- Raffle the dica number
93-
dicas = io.open("dicas.words", r) -- Open file dicas
93+
file = "dicas.words"
94+
dicas = io.open(file) -- Open file dicas
95+
9496
q_dica = dicas:read() -- Read dica number
9597
dicas:close() -- Close the file
9698
math.randomseed(os.time()) -- Create seed for random
@@ -100,7 +102,8 @@ function ForcaGame:SorteiaDica() -- Raffle the dica number
100102
end
101103

102104
function ForcaGame:RetornaDica(ndica) -- Return the name file dica
103-
dicas = io.open("dicas.words", r) -- Open file dicas
105+
file = "dicas.words"
106+
dicas = io.open(file) -- Open file dicas
104107
for i=1, ndica+1, 1 do
105108
dica = dicas:read() -- Read dicas
106109
end
@@ -109,7 +112,8 @@ function ForcaGame:RetornaDica(ndica) -- Return the name file dica
109112
end
110113

111114
function ForcaGame:SorteiaPalavra(banco_sorteado) -- Sorteia Palavra
112-
banco = io.open(banco_sorteado .. ".words", r)
115+
file = banco_sorteado .. ".words"
116+
banco = io.open(file)
113117
num_palavras = banco:read() -- Read number the words
114118
math.randomseed(os.time()) -- Create seed for random
115119
math.random() -- Adicionar mais Random ajudam na melhor aleatoriedade
@@ -341,5 +345,12 @@ function ForcaGame:Boneco(fase) -- Imprime boneco corespondente com os erros
341345
print ("------------------------------------- ")
342346
end
343347
end
348+
349+
function ForcaGame:Clear() -- Limpa a tela de acordo com o sistema operacional
350+
r = os.execute("clear")
351+
if(r == false) then
352+
os.execute("cls")
353+
end
354+
end
344355

345356
return ForcaGame -- Retorna Instancia do Objeto

0 commit comments

Comments
 (0)