Advertisement
BillBodkin

jackTrainStation

Dec 26th, 2016
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. print("Station system activated")
  2. callCounter = 0
  3. --url = "https://script.google.com/macros/s/AKfycbzoL3L5-Yek4DxZUdNwFtCdS7ec2fzyFRp8ZdaMSlc/exec"
  4. url = "http://cablepost.ddns.net/cc/jackTrainStation"
  5. if os.getComputerLabel() == "jackstationbottom" then
  6.     other = "jackstationtop"
  7.     rs = "right"
  8. else
  9.     other = "jackstationbottom"
  10.     rs = "left"
  11. end
  12. print("other: " .. other)
  13. monitor = peripheral.wrap( "top" )
  14. monitor.setTextScale(1)
  15. while true do
  16.     -- status
  17.     if redstone.getInput("bottom") then
  18.         status = http.get(url .. "/status.php?status=" .. os.getComputerLabel()).readAll()
  19.     else
  20.         status = http.get(url .. "/status.php").readAll()
  21.         if status == os.getComputerLabel() then
  22.             status = http.get(url .. "/status.php?status=none").readAll()
  23.         end
  24.     end
  25.     status = http.get(url .. "/status.php").readAll()
  26.     print(status)
  27.     -- call
  28.     -- get call
  29.     c = http.get(url .. "/call.php").readAll()
  30.     if c == os.getComputerLabel() then 
  31.         redstone.setOutput("front", true)
  32.         sleep(1)
  33.         redstone.setOutput("front", false)
  34.     end
  35.     -- set call
  36.     if redstone.getInput(rs) then
  37.         c = http.get(url .. "/call.php?call=" .. other).readAll()
  38.     end
  39.     -- call counter
  40.     if c ~= "none" then
  41.         callCounter = callCounter + 1
  42.     else
  43.         callCounter = 0
  44.     end
  45.     if callCounter > 2 then
  46.         callCounter = 0
  47.         c = http.get(url .. "/call.php?call=none").readAll()
  48.     end
  49.     print(c)
  50.     monitor.clear()
  51.     monitor.setCursorPos(1,1)
  52.     if status == "jackstationbottom" then
  53.         monitor.write( "Status: bottom")
  54.     elseif status == "jackstationtop" then
  55.         monitor.write( "Status: top")
  56.     else
  57.         monitor.write( "Status: unknown")
  58.     end
  59.     monitor.setCursorPos(1,2)
  60.     monitor.write( "Call: " .. c)
  61.     sleep(1)
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement