Advertisement
EtoileDeFeu65

satmanager

Dec 8th, 2023 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | Gaming | 0 0
  1. local term = require("term")
  2. function display()
  3.     local fichier = io.open("satids.txt", "r")
  4.  
  5.     if fichier then
  6.         for ligne in fichier:lines() do
  7.             print(ligne)
  8.         end
  9.         fichier:close()
  10.     else
  11.         print("Erreur. Impossible d'ouvrir le fichier")
  12.     end
  13. end
  14.  
  15. function isValidChoice(choice, validChoices)
  16.     local trouve = false
  17.  
  18.     for _, valeur in ipairs(validChoices) do
  19.         if valeur == input then
  20.             trouve = true
  21.             break
  22.         end
  23.     end
  24.     return trouve
  25. end
  26.  
  27. choice = "a"
  28.  
  29. repeat
  30.     print("\n\n\nTapez une touche pour continuer")
  31.     io.read()
  32.     term.clear()
  33.     print("==========Menu==========\n1) Afficher les ids des satellites\n2) Ajouter un id de satellite\n3) Quitter")
  34.     local choice = io.read()
  35.     local validChoices = {"1", "2", "3"}
  36.     if isValidChoice(choice, validChoices) then
  37.         if choice == "1" then
  38.             display()
  39.             os.sleep(0.1)
  40.         end
  41.     else
  42.         print("Choix invalide, réessaie")
  43.     end
  44. until choice == "3"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement