estephane

and

Apr 14th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. --                  Prática e exemplos com operadores lógicos (and)
  2.  
  3. function verificarAtirar()
  4. tecla = io.read()
  5. return tecla == "F"  -- estou retornando imediatamente o valor da função
  6. end
  7.  
  8. if verificarAtirar () then
  9. print (" ATIVAR!!! BOOOM!!!")
  10. end
  11.  
  12.  
  13.  
  14. --                             outro exemplo
  15.  
  16.  
  17. function verificarAtirar()
  18. tecla = io.read()
  19. return tecla == "F"
  20. end
  21. municao = 1
  22.  function verificarmunicao()
  23.  if municao >= 1 then
  24.  return true
  25.  else
  26.  return false
  27.    end
  28.  end
  29.  
  30.  if verificarAtirar() and verificarmunicao() then
  31.  print (" ATIRAR!!! BOOOOM!!!!")
  32.   municao = municao - 1
  33.   --[[como foi estabelecido anteriormente pela variavel municao
  34. apenas uma munição se eu tiro uma fica 1-1=0 então isso indica
  35. que a cada tiro eu tenho menos uma munição]]--
  36.   end
  37.   print("Você ainda tem isso de munição: " .. municao)
Advertisement
Add Comment
Please, Sign In to add comment