Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ComputerCraft Screen Calibrator
- -- For whenever you need a bigger display
- -- but the monitors change IDs on reboots
- if (not(fs.exists("monitorScreen")) or (monitorScreen == nil)) then
- -- Put this in startup file: os.loadAPI("/monitorScreen")
- shell.run("delete /monitorScreen")
- shell.run("pastebin get SeNab0j9 /monitorScreen")
- term.clear()
- term.setCursorPos(1,1)
- term.write('Put this in startup file:')
- term.setCursorPos(1,3)
- term.write('os.loadAPI("/monitorScreen")')
- term.setCursorPos(1,4)
- return
- end
- local monitors_selectedLine = {}
- local monitors = monitorScreen.getMonitors()
- function drawMonitor(monitor_name)
- local monitor = peripheral.wrap(monitor_name)
- local id = monitorScreen.getMonitorID(monitor_name)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- monitor.setTextScale(2)
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("Screen name: "..monitor_name)
- monitor.setCursorPos(1,2)
- monitor.write("Current screen: "..id)
- monitor.setCursorPos(1,4)
- monitor.write("Screen selection:")
- for i=1, #monitors, 1 do
- monitor.setCursorPos(1,i+5)
- if (id==i) then
- monitor.setBackgroundColor(colors.green)
- monitor.write("Active : Screen "..i)
- else
- if (monitors_selectedLine[monitor_name] == nil) then
- monitor.setBackgroundColor(colors.black)
- monitor.write("Select : Screen "..i)
- else
- if monitors_selectedLine[monitor_name] == i then
- monitor.setBackgroundColor(colors.orange)
- monitor.write("Selected: Screen "..i)
- else
- monitor.setBackgroundColor(colors.black)
- monitor.write("Select : Screen "..i)
- end
- end
- end
- end
- monitor.setTextColor(colors.white)
- if monitors_selectedLine[monitor_name] == nil then
- monitor.setBackgroundColor(colors.green)
- monitors_selectedLine[monitor_name] = id
- else
- if monitors_selectedLine[monitor_name] == id then
- monitor.setBackgroundColor(colors.green)
- else
- monitor.setBackgroundColor(colors.orange)
- end
- end
- monitor.setCursorPos(20,2)
- monitor.write("[SAVE]")
- monitor.setBackgroundColor(colors.black)
- end
- for _, monitor_name in pairs(monitors) do
- drawMonitor(monitor_name)
- end
- while true do
- local event, monitor, x, y = os.pullEvent()
- if (event == "monitor_touch") then
- if ((y > 5) and (y<=#monitors+5)) then
- monitors_selectedLine[monitor] = y-5
- drawMonitor(monitor)
- end
- if (y==2) then
- if ((x>=20) and (x<=25)) then
- monitorScreen.setMonitorID(monitor, monitors_selectedLine[monitor])
- drawMonitor(monitor)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement