Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Station system activated")
- callCounter = 0
- --url = "https://script.google.com/macros/s/AKfycbzoL3L5-Yek4DxZUdNwFtCdS7ec2fzyFRp8ZdaMSlc/exec"
- url = "http://cablepost.ddns.net/cc/jackTrainStation"
- if os.getComputerLabel() == "jackstationbottom" then
- other = "jackstationtop"
- rs = "right"
- else
- other = "jackstationbottom"
- rs = "left"
- end
- print("other: " .. other)
- monitor = peripheral.wrap( "top" )
- monitor.setTextScale(1)
- while true do
- -- status
- if redstone.getInput("bottom") then
- status = http.get(url .. "/status.php?status=" .. os.getComputerLabel()).readAll()
- else
- status = http.get(url .. "/status.php").readAll()
- if status == os.getComputerLabel() then
- status = http.get(url .. "/status.php?status=none").readAll()
- end
- end
- status = http.get(url .. "/status.php").readAll()
- print(status)
- -- call
- -- get call
- c = http.get(url .. "/call.php").readAll()
- if c == os.getComputerLabel() then
- redstone.setOutput("front", true)
- sleep(1)
- redstone.setOutput("front", false)
- end
- -- set call
- if redstone.getInput(rs) then
- c = http.get(url .. "/call.php?call=" .. other).readAll()
- end
- -- call counter
- if c ~= "none" then
- callCounter = callCounter + 1
- else
- callCounter = 0
- end
- if callCounter > 2 then
- callCounter = 0
- c = http.get(url .. "/call.php?call=none").readAll()
- end
- print(c)
- monitor.clear()
- monitor.setCursorPos(1,1)
- if status == "jackstationbottom" then
- monitor.write( "Status: bottom")
- elseif status == "jackstationtop" then
- monitor.write( "Status: top")
- else
- monitor.write( "Status: unknown")
- end
- monitor.setCursorPos(1,2)
- monitor.write( "Call: " .. c)
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement