Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("bottom")
- local sensor = peripheral.wrap("back")
- local monitor = peripheral.wrap("top")
- monitor.setTextScale(0.5)
- if rs.getInput("top") then
- return
- end
- rs.setOutput("front",true)
- function getCartAt(x,y,z)
- local carts = sensor.getMinecartIds()
- for num, id in pairs(carts) do
- local cart
- pcall(function() cart = sensor.getMinecartData(id) end)
- if cart then
- local pos = cart.position
- if (math.abs(x - pos.x) < 1.0) and (math.abs(y - pos.y) < 1.0) and (math.abs(z - pos.z) < 1.0) then
- return cart
- end
- end
- end
- return nil
- end
- local cart = nil
- os.startTimer(1)
- while true do
- local event, senderId, message = os.pullEvent()
- if event == "timer" then
- monitor.clear()
- cart = getCartAt(-1,1,1)
- --if cart then
- --print(cart.position.x..", "..cart.position.y..", "..cart.position.z)
- --os.sleep(10000)
- --end
- if cart then
- if cart.riddenBy then
- local username = cart.riddenBy.username
- local heldItem = cart.riddenBy.heldItem
- local validTicket = false
- local destination = "none"
- local ticketid = "ID: ungueltig"
- if heldItem then
- if heldItem.printout then
- local text = heldItem.printout.text
- if text then
- destination = text[1]
- ticketid = text[2]
- validTicket = true
- end
- end
- end
- if validTicket then
- monitor.setCursorPos(1,1)
- monitor.write("Gute Fahrt nach")
- monitor.setCursorPos(1,2)
- monitor.write(destination)
- monitor.setCursorPos(1,3)
- monitor.write(username..".")
- monitor.setCursorPos(1,5)
- monitor.write(ticketid)
- print("abfahrt")
- rednet.broadcast("abfahrt")
- rs.setOutput("front",false)
- os.sleep(3)
- rs.setOutput("front",true)
- else
- monitor.setCursorPos(1,1)
- monitor.write("Wilkommen")
- monitor.setCursorPos(1,2)
- monitor.write(username)
- monitor.setCursorPos(1,4)
- monitor.write("Die Fahrkarte")
- monitor.setCursorPos(1,5)
- monitor.write("vorzeigen bitte.")
- end
- end
- else
- rs.setOutput("left",true)
- os.sleep(0.1)
- rs.setOutput("left",false)
- end
- os.startTimer(1)
- end
- if event == "rednet_message" then
- if message then
- if message == "abfahrt" then
- print("Wait 3 sec...")
- os.sleep(3)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement