Advertisement
Guest User

startup

a guest
Feb 18th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. rs.setOutput("left", true)
  2.  
  3. mag = peripheral.wrap("right")
  4.  
  5. function accredita()
  6.   term.clear()
  7.   term.setCursorPos(1,1)
  8.   print("Inserisci la carta")
  9.   mag.setInsertCardLight(true)
  10.   _, data, side = os.pullEvent("mag_swipe")
  11.   mag.setInsertCardLight(false)
  12.   tab = textutils.unserialize(data)
  13.  
  14.   if tab == nil or tab.credito == nil or tab.label == nil then
  15.     print("Carta non valida!")
  16.     sleep(2)
  17.     os.reboot()
  18.   end
  19.  
  20.   if tab.credito < 0 or tab.label ~= "BCB" then
  21.     print("Carta non valida!")
  22.     sleep(2)
  23.     os.reboot()
  24.   end
  25.   rs.setOutput("left", false)
  26.   print("Inserisci i soldi qua sotto e clicca un tasto\nqualunque quando hai fatto")
  27.   os.pullEvent("key")
  28.   rs.setOutput("left", true)
  29.   print("Sto contando...")
  30.   rednet.open("back")
  31.   rednet.send(12, "conta")
  32.   id, msg = rednet.receive()
  33.   if id == 12 then
  34.     ncredito = tab.credito + tonumber(msg)
  35.   end
  36.   tab.credito = ncredito
  37.   print("Inserire nuovamente la carta per confermare")
  38.   mag.beginWrite(textutils.serialize(tab), "BC Bank")
  39.   os.pullEvent("mag_write_done")
  40.   print("Nuovo credito: "..tostring(ncredito))
  41.   sleep(3)
  42.   os.reboot()
  43. end
  44.  
  45. term.clear()
  46. term.setCursorPos(1,1)
  47. term.write("Banca Di BlueCity - Accredito su carta")
  48. term.setCursorPos(1, 3)
  49. print("[1] Inserisci soldi")
  50. term.setCursorPos(1, 5)
  51. term.write(">> ")
  52. s = read()
  53. if s == "1" then
  54.   accredita()
  55. else
  56.   os.reboot()
  57. end
  58.  
  59. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement