Advertisement
Bolodefchoco_LUAXML

[Pedido] Accents

Oct 12th, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. data = {}
  2.  
  3. table.find = function(list,value)
  4.     for k,v in next,list do
  5.         if v.chairN == value then
  6.             return true
  7.         end
  8.     end
  9.     return false
  10. end
  11.  
  12. main = function()
  13.     repeat
  14.         local name,day,chair
  15.         os.execute("cls")
  16.         io.write("Nome do usuario: ")
  17.         name = io.read()
  18.         os.execute("cls")
  19.         local days = {"Quarta-feira","Quinta-feira","Sexta-feira","Sabado","Domingo"}
  20.         io.write("Dia da semana:\n\t1. Quarta\n\t2. Quinta\n\t3. Sexta\n\t4. Sabado\n\t5. Domingo\n")
  21.         repeat
  22.             day = tonumber(io.read())
  23.         until day > 0 and day < 6
  24.         os.execute("cls")
  25.         day = days[day]
  26.         local a = ""
  27.         do
  28.             local i, t, f = 1, 200, 1
  29.             while i <= t do
  30.                 local v = i
  31.                 if table.find(data,i) then
  32.                     f = f + 1
  33.                     i = i + 1
  34.                 end
  35.                 a = a .. (i<10 and "00" or i<100 and "0" or "") .. i .. " "
  36.                 if i+f%20 == 0 then
  37.                     a = a .. "\n"
  38.                 end
  39.                 i = i + 1
  40.             end
  41.         end
  42.         io.write("Acentos disponiveis\n\n"..a.."\n\nNumero do acento: ")
  43.         repeat
  44.             chair = tonumber(io.read())
  45.         until chair > 0 and chair < 201
  46.         os.execute("cls")
  47.         local i,j = 1,chair%20
  48.         for k = 1,chair do
  49.             if k%21 == 0 then
  50.                 i = i + 1
  51.             end
  52.         end
  53.         data[#data + 1] = {name = name, chair = ("Fileira %d | Coluna %d | Acento %d"):format(i,j,chair), day = day, chairN = chair}
  54.         io.write("Registrar novo cliente? (s/n): ")
  55.         local new = io.read():lower()
  56.     until new == "n"
  57.     os.execute("cls")
  58.     for k,v in next,data do
  59.         local form = "\tNome: %s\n\tAcento: %s\n\tDia: %s\n\n"
  60.         io.write(form:format(v.name,v.chair,v.day))
  61.     end
  62.     os.execute("pause")
  63. end
  64.  
  65. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement