Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitorConnection = "top"
- local textScale = 5
- local lines = {"The Scenic", "Route"}
- local delay = 2
- local useColor = true
- --used internally.
- monitor = nil
- local lColor = 1
- local nColor = 1
- local x = 1
- local y = 1
- local function centerText(cString)
- local offset = 1
- if string.len(cString) < x then
- offset = math.floor((x - string.len(cString)) / 2) + 1
- else
- offset = 1
- end
- return offset
- end
- local function getColor()
- if monitor.isColor() then
- while lColor == nColor do
- nColor = math.random(1,15)
- end
- lColor = nColor
- monitor.setTextColor(nColor)
- end
- end
- print("Checking for Monitor.")
- while monitor == nil do
- monitor = peripheral.wrap(monitorConnection)
- os.sleep(1)
- end
- print("Monitor Found, Running Program.")
- monitor.setTextScale(textScale)
- x, y = monitor.getSize()
- while true do
- monitor.clear()
- if useColor == true then
- getColor()
- end
- for k,v in ipairs(lines) do
- if k <= y then
- monitor.setCursorPos(centerText(v),k)
- monitor.write(v)
- end
- end
- os.sleep(delay)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement