Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[ VARS ]--
- monitor = peripheral.wrap("back")
- local monitorX,monitorY = term.getSize()
- timeTable = {}
- timeTable = { { {6.32,1,"Grottköping"}, --[ DEPARTURES ]--
- {7.15,3,"Roffeborg"},
- {7.25,3,"Roffeborg"},
- {8.15,3,"Roffeborg"},
- {8.28,3,"Hashtofta"},
- {8.45,3,"Roffeborg"},
- {9.12,3,"Roffeborg"},
- {11.55,3,"Roffeborg"},
- {15.15,1,"Petershus"},
- {18.15,2,"Rökköping"},
- {18.19,1,"Roffeborg"},
- {19.37,3,"Roffeborg"},
- {22.38,1,"Petershus"},
- },
- { {12.31,1,"Grottköping"}, --[ ARRIVALS ]--
- {14.55,3,"Roffeborg"},
- {15.15,1,"Petershus"},
- {18.11,2,"Rökköping"},
- {18.11,1,"Roffeborg"},
- {19.31,3,"Roffeborg"},
- {22.38,1,"Petershus"},
- }
- }
- --[ FUNCTIONS ]--
- function writeInfo()
- -- rensa skärmen
- for i=5,18 do
- term.setCursorPos(1,i)
- term.clearLine()
- end
- local lines = 0
- local maxLines = 12
- -- [ DEPARTURES ]--
- -- SKRIV BARA UT DE TÅG SOM INTE GÅTT ÄN
- for i=1,#timeTable[1] do
- if lines < maxLines then
- local tMinutes = math.fmod (timeTable[1][i][1], 1) * 100/60
- local tHours = math.floor (timeTable[1][i][1])
- local tTime = tHours + tMinutes --skapar en float med tiden
- local sTime = ""
- if os.time() < tTime then
- --formattera tiden
- if math.floor (timeTable[1][i][1]) < 10 then
- sTime = sTime.."0"
- end
- sTime = sTime..timeTable[1][i][1]
- term.setCursorPos(2,5+lines)
- local line = string.format("%5s %2i %15s",
- sTime,
- timeTable[1][i][2],
- timeTable[1][i][3])
- write(line)
- lines = lines + 1
- end
- end
- end
- -- SKRIV UT TÅG FÖR IMORGON
- for i=1,#timeTable[1] do
- if lines < maxLines then
- local tMinutes = math.fmod (timeTable[1][i][1], 1) * 100/60 --minuter
- local tHours = math.floor (timeTable[1][i][1])
- local tTime = tHours + tMinutes --skapar en float med tiden
- local sTime = ""
- if os.time() > tTime then
- --formattera tiden
- if math.floor (timeTable[1][i][1]) < 10 then
- sTime = sTime.."0"
- end
- sTime = sTime..timeTable[1][i][1]
- term.setCursorPos(1,5+lines)
- local line = string.format("*%5s %2i %15s",
- sTime,
- timeTable[1][i][2],
- timeTable[1][i][3])
- write(line)
- lines = lines + 1
- end
- end
- end
- -- [ ARRIVALS ]--
- lines = 0
- -- SKRIV BARA UT DE TÅG SOM INTE GÅTT ÄN
- for i=1,#timeTable[2] do
- if lines < maxLines then
- local tMinutes = math.fmod (timeTable[2][i][1], 1) * 100/60
- local tHours = math.floor (timeTable[2][i][1])
- local tTime = tHours + tMinutes --skapar en float med tiden
- local sTime = ""
- if os.time() < tTime then
- --formattera tiden
- if math.floor (timeTable[2][i][1]) < 10 then
- sTime = sTime.."0"
- end
- sTime = sTime..timeTable[2][i][1]
- term.setCursorPos(27,5+lines)
- local line = string.format("%5s %2i %15s",
- sTime,
- timeTable[2][i][2],
- timeTable[2][i][3])
- write(line)
- lines = lines + 1
- end
- end
- end
- -- SKRIV UT TÅG FÖR IMORGON
- for i=1,#timeTable[2] do
- if lines < maxLines then
- local tMinutes = math.fmod (timeTable[2][i][1], 1) * 100/60 --minuter
- local tHours = math.floor (timeTable[2][i][1])
- local tTime = tHours + tMinutes --skapar en float med tiden
- local sTime = ""
- if os.time() > tTime then
- --formattera tiden
- if math.floor (timeTable[2][i][1]) < 10 then
- sTime = sTime.."0"
- end
- sTime = sTime..timeTable[2][i][1]
- term.setCursorPos(26,5+lines)
- local line = string.format("*%5s %2i %15s",
- sTime,
- timeTable[2][i][2],
- timeTable[2][i][3])
- write(line)
- lines = lines + 1
- end
- end
- end
- end
- function cPrint(msg,yPos)
- term.setCursorPos((monitorX-string.len(msg))/2, yPos)
- write(msg)
- end
- function updateBoard()
- while true do
- local sTime = ""
- term.setCursorPos(1,1)
- term.clearLine()
- if math.floor (os.time()) < 10 then
- sTime = sTime.."0"
- end
- sTime = sTime..textutils.formatTime(os.time(), true)
- cPrint(sTime,1)
- writeInfo()
- sleep(1)
- end
- end
- function writeHeader()
- term.setCursorPos(1,2)
- print("DEPARTURES ARRIVALS\n Time # Destination Time # From")
- end
- function clearMonitor()
- monitor.setBackgroundColor(colors.green)
- monitor.setTextColor(colors.yellow)
- monitor.clear()
- term.setCursorPos(1,1)
- end
- --[ INIT, MAIN ]--
- term.redirect(monitor)
- clearMonitor()
- writeHeader()
- updateBoard()
- -- [ END ]--
- term.restore()
Advertisement
Add Comment
Please, Sign In to add comment