Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor_left = peripheral.wrap("monitor_44")
- monitor_middle = peripheral.wrap("monitor_45")
- monitor_right = peripheral.wrap("monitor_46")
- Active_Monitor = nil
- function calculateCenter(w, text)
- return math.floor((w - string.len(text)) / 2) + 1
- end
- function writeMonitor(x, y, text)
- Active_Monitor.setCursorPos(x, y)
- Active_Monitor.write(text)
- end
- function clearBackground(colourr, textColour)
- Active_Monitor.setBackgroundColor(colourr)
- Active_Monitor.setTextColor(textColour)
- Active_Monitor.clear()
- end
- function ClearMonitor()
- Active_Monitor.setTextColor(colours.black)
- Active_Monitor.setBackgroundColor(colours.black)
- Active_Monitor.clear()
- Active_Monitor.setCursorPos(1,1)
- end
- function DrawText(xPos, yPos, text, textColour, backgroundColour)
- Active_Monitor.setBackgroundColor(backgroundColour)
- Active_Monitor.setTextColor(textColour)
- Active_Monitor.setCursorPos(xPos,yPos)
- Active_Monitor.write(text)
- end
- function DrawCenteredHorizontal(xPos, yPos, width, text, textColour, backgroundColour)
- -- width could be the size of your monitor, or anything else. this means it
- -- doesn't have to stretch your entire monitor's if you want. imagine
- -- it as a rectangle and the text is in the center.
- local textLength = string.len(text)
- local centerX = (width / 2) - (textLength / 2)
- DrawText(xPos + centerX, yPos, text, textColour, backgroundColour)
- end
- function DrawLineH(xPos, yPos, lineLength, colour)
- Active_Monitor.setBackgroundColor(colour)
- Active_Monitor.setTextColor(colour)
- Active_Monitor.setCursorPos(xPos,yPos)
- Active_Monitor.write(string.rep(" ", lineLength))
- end
- function DrawLineV(xPos, yPos, width, lineHeight, colour)
- Active_Monitor.setBackgroundColor(colour)
- for i = 1, lineHeight, 1 do
- Active_Monitor.setCursorPos(xPos, yPos + (i - 1))
- Active_Monitor.write(string.rep(" ", width))
- end
- end
- function DrawSquare(xPos, yPos, nWidth, nHeight, backgroundColour)
- Active_Monitor.setBackgroundColor(backgroundColour)
- for i = 1, math.ceil(nHeight), 1 do
- Active_Monitor.setCursorPos(xPos, yPos + (i - 1))
- Active_Monitor.write(string.rep(" ", nWidth))
- end
- end
- function ProgressBar(xPos, yPos, width, value, maxValue, backgroundColour, progressColour)
- DrawLineH(xPos, yPos, width, backgroundColour) --backgoround bar
- local barSize = math.floor((value/maxValue) * width)
- DrawLineH(xPos, yPos, barSize, progressColour) --progress so far
- end
- WINDOW_TITLE_COLOUR = colours.lightGrey
- WINDOW_CLIENT_COLOUR = colours.grey
- progress_val = 20
- function DrawWindow(title, x, y, w, h)
- DrawSquare(x, y, w, 1, WINDOW_TITLE_COLOUR)
- DrawText(x, y, title, colours.black, WINDOW_TITLE_COLOUR)
- DrawSquare(x, y + 1, w, h - 1, WINDOW_CLIENT_COLOUR)
- local buttonStart = x + w - 4
- DrawText(buttonStart, y, "-", colours.white, colours.blue)
- DrawText(buttonStart + 1, y, "[]", colours.white, colours.blue)
- DrawText(buttonStart + 3, y, "x", colours.red, colours.blue)
- end
- function drawLeftMonitor()
- clearBackground(colours.white, colours.black)
- DrawWindow("hello window xd", 2, 3, 20, 8)
- DrawWindow("eek", 9, 12, 8, 5)
- end
- function drawMiddleMonitor()
- clearBackground(colours.white, colours.black)
- DrawWindow("hello window xd", 7, 3, 24, 12)
- ProgressBar(8, 5, 22, progress_val, 100, colours.blue, colours.lightBlue)
- end
- function drawRightMonitor()
- clearBackground(colours.white, colours.black)
- DrawWindow("xd", 3, 7, 10, 7)
- end
- function main()
- Active_Monitor = monitor_left
- drawLeftMonitor()
- Active_Monitor = monitor_middle
- drawMiddleMonitor()
- Active_Monitor = monitor_right
- drawRightMonitor()
- Active_Monitor = nil
- progress_val = progress_val + 10
- if (progress_val == 110) then
- progress_val = 0
- end
- os.sleep(0.5)
- end
- while true do
- main()
- end
Add Comment
Please, Sign In to add comment