Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mainId = 2
- stationName = "Oak"
- stationZone = 1
- mon = peripheral.wrap("monitor_1")
- mag = peripheral.wrap("back")
- rfid = peripheral.wrap("top")
- rednet.open("right")
- function midPrint(text,sety)
- x,y = mon.getSize()
- len = string.len(text)
- setx = (x/2)-(len/2)+1
- mon.setCursorPos(setx,sety)
- mon.write(text)
- end
- rfid.scan()
- while true do
- mon.clear()
- midPrint("Station " .. stationName,2)
- mag.setInsertCardLight(true)
- event,data = os.pullEvent()
- mag.setInsertCardLight(false)
- if event == "mag_swipe" then
- toSend = "1-" .. data
- print(toSend)
- rednet.send(mainId,toSend)
- sId, msg = rednet.receive()
- if msg == "invalid" then
- midPrint("Ticket Invalide",3)
- os.sleep(3)
- else
- midPrint("Ticket Valide",3)
- midPrint("Il reste " .. msg,4)
- midPrint("utilisations",5)
- redstone.setOutput("bottom",true)
- os.sleep(5)
- redstone.setOutput("bottom",false)
- end
- os.reboot()
- elseif event == "rfid_scan_done" then
- rfid.scan()
- elseif event == "rfid_detected" then
- if data ~= "top" then
- toSend = "4-" .. data
- rednet.send(mainId,toSend)
- sId, msg = rednet.receive()
- if msg == "invalid" then
- midPrint("Pass Invalide",3)
- os.sleep(3)
- else
- midPrint("Bienvenue " .. data,3)
- midPrint("Il reste " .. msg,4)
- midPrint("utilisations",5)
- redstone.setOutput("bottom",true)
- os.sleep(5)
- redstone.setOutput("bottom",false)
- end
- end
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement