Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Settings]]--
- --Peripherals
- local modemName = "back"
- local monitorName = "monitor_0"
- local chestName = "container_chest_1"
- local channel = 1
- --relative to chest
- local projectorSide = "left"
- --Slots
- local projectorModeSlot = 1
- local projectorPatternSlot = 5
- --Id's
- local patternId = 387
- local modeStabelize = 280
- local modeClear = 281
- --Design
- design =
- {
- selectedColorText = colors.red,
- selectedColorBack = colors.yellow,
- deselectColorText = colors.white,
- deselectColorBack = colors.green,
- actionColoText = colors.white,
- actionColorBack = colors.red,
- sideBorder = 2
- topBorder = 4
- bottomBorder = 4
- }
- --[[Variables & peripherals]]--
- local modem = peripheral.wrap(modemName)
- local monitor = peripheral.wrap(monitorName)
- local chest = peripheral.wrap(chestName)
- modem.open(channel)
- local width, height = monitor.getSize()
- local objects = {}
- local buttons = {}
- --[[Functions]]--
- local function round(number)
- return math.floor(number + 0.5)
- end
- local function clear()
- term.clear()
- term.setCursorPos(1,1)
- monitor.setTextColor(colors.white)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1,1)
- monitor.clear()
- end
- local function scanForModes()
- local chestInv = chest.getAllStacks()
- local modes = {}
- for i, data in pairs(chestInv) do
- if data.id == patternId then
- modes[i] = data.name
- end
- end
- return modes
- end
- local function drawButton(x1, y1, x2, y2, text, textColor, backgroundColor)
- monitor.setBackgroundColor(backgroundColor)
- monitor.setTextColor(textColor)
- for x = x1, x2 do
- for y = y1, y2 do
- monitor.setCursorPos(x, y)
- monitor.write(" ")
- end
- end
- monitor.setCursorPos(round(x1 + math.abs(x2 - x1) / 2 - #text / 2), round(math.abs(y2 - y1) / 2))
- monitor.write(text)
- table.insert(buttons, {text = text, x1 = x1, y1 = y2, x2 = x2, y2 = y1})
- end
- local function printModes(data)
- local longest = 0
- for i, j in pairs(data.modes) do
- if #j > longest then
- longest = #j
- end
- end
- for colums = 20, 1, -1 do
- if width - 2 * data.design.sideBorder - colums * longest >= 2(colums - 1) then
- break
- end
- end
- local rows = math.ceil(#data.modes / colums)
- local space = (width - 2 * data.design.sideBorder - colums * longest) / (colors - 1)
- for rowPos = 1, rows do
- for columPos = 1, colums do
- local pos = columPos + rowPos * colums
- local x1 = data.design.sideBorder + (columPos - 1) * (longest + space)
- local x2 = x1 + longest
- local y = data.design.topBorder
- end
- end
- end
- --[[Main program]]--
- local data = {}
- data.design = design
- clear()
- drawButton(16, 1, 31, 10, "Henryk", colors.white, colors.blue)
- print(textutils.serialize(buttons))
Advertisement
Add Comment
Please, Sign In to add comment