Advertisement
Guest User

startup

a guest
Oct 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. mainId = 2
  2. stationName = "Oak"
  3. stationZone = 1
  4.  
  5. mon = peripheral.wrap("monitor_1")
  6. mag = peripheral.wrap("back")
  7. rfid = peripheral.wrap("top")
  8. rednet.open("right")
  9.  
  10. function midPrint(text,sety)
  11.   x,y = mon.getSize()
  12.   len = string.len(text)
  13.   setx = (x/2)-(len/2)+1
  14.   mon.setCursorPos(setx,sety)
  15.   mon.write(text)
  16. end
  17.  
  18. rfid.scan()
  19.  
  20. while true do
  21.   mon.clear()
  22.   midPrint("Station " .. stationName,2)
  23.   mag.setInsertCardLight(true)
  24.   event,data = os.pullEvent()
  25.   mag.setInsertCardLight(false)
  26.   if event == "mag_swipe" then
  27.  
  28.     toSend = "1-" .. data
  29.     print(toSend)
  30.     rednet.send(mainId,toSend)
  31.     sId, msg = rednet.receive()
  32.     if msg == "invalid" then
  33.       midPrint("Ticket Invalide",3)
  34.       os.sleep(3)
  35.     else
  36.       midPrint("Ticket Valide",3)
  37.       midPrint("Il reste " .. msg,4)
  38.       midPrint("utilisations",5)
  39.       redstone.setOutput("bottom",true)
  40.       os.sleep(5)
  41.       redstone.setOutput("bottom",false)
  42.     end
  43.     os.reboot()
  44.   elseif event == "rfid_scan_done" then
  45.     rfid.scan()
  46.   elseif event == "rfid_detected" then
  47.     if data ~= "top" then
  48.       toSend = "4-" .. data
  49.       rednet.send(mainId,toSend)
  50.       sId, msg = rednet.receive()
  51.       if msg == "invalid" then
  52.         midPrint("Pass Invalide",3)
  53.         os.sleep(3)
  54.       else
  55.         midPrint("Bienvenue " .. data,3)
  56.         midPrint("Il reste " .. msg,4)
  57.         midPrint("utilisations",5)
  58.         redstone.setOutput("bottom",true)
  59.         os.sleep(5)
  60.         redstone.setOutput("bottom",false)
  61.       end
  62.     end
  63.     os.reboot()
  64.   end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement