Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --label, row, column, background, text color
- local args = { ... }
- --Set variables
- local length = 10
- local height = 3
- local label = args[1] or "EMPTY"
- local tx = args[2] or 1
- local ty = args[3] or 1
- local color = args[4] or colors.blue
- local text = args[5] or colors.white
- --Set monitor properties
- mon = peripheral.wrap("monitor_1")
- mon.setTextScale(0.5)
- --Calculate offset and position
- offsetX = (tx-1) * length + 1
- posX = offsetX + math.floor((length - #label)/2)
- posY = (ty-1) * height + 1
- --Draw button first
- mon.setBackgroundColor(tonumber(color))
- mon.setTextColor(tonumber(text))
- mon.setCursorPos(offsetX,posY)
- mon.write(string.rep(" ", length))
- mon.setCursorPos(offsetX,posY+1)
- mon.write(string.rep(" ", length))
- mon.setCursorPos(offsetX,posY+2)
- mon.write(string.rep(" ", length))
- --Draw label afterwards
- mon.setCursorPos(posX,posY+1)
- mon.write(label)
Advertisement
Add Comment
Please, Sign In to add comment