Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- * Monitorseite: left, right, back, bottom,
- -- down, up
- local monitor = peripheral.wrap("back")
- -- * SchriftgråB6sse: 1 oder gråB6sser
- local size = 2.5
- function createBar(yPos, start, stop, time, color)
- interval = math.floor((start - stop) / (time * 10))
- if (interval > 0) then
- for i = start,stop,(interval * (-1)) do
- if (i < stop) then
- return
- end
- monitor.setCursorPos(1,yPos)
- monitor.clearLine()
- monitor.setBackgroundColor(color)
- for j = stop,i,1 do
- monitor.write(" ")
- end
- monitor.setBackgroundColor(colors.black)
- sleep(time)
- end
- end
- end
- function setBackground(color)
- monitor.setBackgroundColor(color)
- end
- function getColor(color)
- if (color == "f") then
- return 1
- elseif (color == "6") then
- return 2
- elseif (color == "4") then
- return 4
- elseif (color == "b") then
- return 8
- elseif (color == "e") then
- return 16
- elseif (color == "a") then
- return 32
- elseif (color == "d") then
- return 64
- elseif (color == "8") then
- return 128
- elseif (color == "7") then
- return 256
- elseif (color == "3") then
- return 512
- elseif (color == "5") then
- return 1024
- elseif (color == "9") then
- return 2048
- elseif (color == "1") then
- return 4096
- elseif (color == "2") then
- return 8192
- elseif (color == "c") then
- return 16384
- elseif (color == "0") then
- return 32768
- end
- end
- function clear()
- monitor.clear()
- end
- function createButton(yPos, height, xPos, length, name, color)
- for y = 1, height do
- monitor.setCursorPos(xPos, (y - 1) + yPos)
- monitor.setBackgroundColor(color)
- if (y == math.floor((height / 2) + 0.5)) then
- number = math.floor((length - name:len()) + 0.5)
- for x = 0, number do
- if (x == math.floor((number / 2) + 0.5)) then
- monitor.setTextColor(colors.black)
- monitor.write(name)
- else
- monitor.write(" ")
- end
- end
- else
- for x = 1, length do
- monitor.write(" ")
- end
- end
- monitor.setBackgroundColor(colors.black)
- end
- end
- function msg(line, text)
- monitor.setCursorPos(1, line)
- monitor.setTextColour(1)
- monitor.setTextScale(size)
- local start = text:find("&")
- local stop = 0
- local color = ""
- if (start == nil) then
- monitor.write(text)
- else
- if (start > 1) then
- monitor.write(text:sub(0, start - 1))
- end
- while (start ~= nil) do
- stop = text:find("&", start + 2)
- color = text:sub(start + 1, start + 1)
- monitor.setTextColor(getColor(color))
- if (stop == nil) then
- monitor.write(text:sub(start + 2))
- break
- else
- monitor.write(text:sub(start + 2, stop - 1))
- start = stop
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement