Advertisement
fyrkantis

ViewSchedule

Feb 18th, 2025 (edited)
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function scheduleFromFile(path)
  2.     local file = fs.open(path, "r")
  3.     local body = file.readAll()
  4.     file.close()
  5.     return textutils.unserialize(body)
  6. end
  7.  
  8. function scheduleFromStation()
  9.     return peripheral.find("Create_Station").getSchedule()
  10. end
  11.  
  12. local args = {...}
  13. local filePath = args[1]
  14. local schedule
  15. if filePath == nil then
  16.     schedule = scheduleFromStation()
  17. else
  18.     schedule = scheduleFromFile(filePath)
  19. end
  20.  
  21. local color = schedule.color
  22. if color == nil then
  23.     color = 2048
  24. end
  25. term.setTextColor(colors.white)
  26. term.setBackgroundColor(colors.black)
  27. term.clear()
  28.  
  29. local i = 1
  30. for _, entry in ipairs(schedule.entries) do
  31.     if entry.instruction.id == "create:destination" then
  32.         local name = entry.instruction.data.text:gsub("%s%d+$", "")
  33.         term.setCursorPos(4, i)
  34.         term.write(name)
  35.         i = i + 1
  36.     end
  37. end
  38. term.setBackgroundColor(color)
  39. for j=1,i-1 do
  40.     term.setCursorPos(2, j)
  41.     term.write(" ")
  42. --    if j == 1 or j == i-1 then
  43. --        term.write("O")
  44. --    else
  45. --        term.write("|")
  46. --    end
  47. end
  48. term.setBackgroundColor(colors.black)
  49. term.setCursorPos(1, i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement