Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Display - program for managing terminal redirect
- By BigShinyToys
- ]]--
- print("locating screens")
- local function grabScreens()
- local tScreen = {}
- for _,side in pairs(rs.getSides()) do
- if peripheral.isPresent(side) then
- local sType = peripheral.getType(side)
- if sType == "monitor" then
- table.insert(tScreen,{["type"] = "direct",["side"] = side})
- elseif sType == "modem" then
- if peripheral.call(side,"isWireless") then
- print("WIFI not suported yet")
- else
- print("Expoloring Network "..side)
- local tDevices = peripheral.call(side,"getNamesRemote")
- local pings = 0
- print(tostring(#tDevices).." devices found.")
- for _,device in pairs(tDevices) do
- local sType = peripheral.call(side,"getTypeRemote",device)
- if sType == "monitor" then
- table.insert(tScreen,{["type"] = "wire",["modemSide"] = side,["deviceID"] = device})
- pings = pings + 1
- end
- end
- print("found "..tostring(pings).." monitors out of "..tostring(#tDevices).." devices")
- end
- end
- else
- print(side.." No peripheral Present")
- end
- end
- return tScreen
- end
- local function connect(tMonitor)
- local termX,termY = term.getSize()
- local tFunctions = {"write","scroll","setCursorPos","setCursorBlink","getCursorPos",
- "getSize","clear","clearLine","setTextColour","setTextColor", -- setTextScale
- "setBackgroundColour","setBackgroundColor","isColour","isColor",}
- local tPassed = {}
- tPassed.direct = {}
- tPassed.wire = {}
- -- evluate candidats
- for _,device in pairs(tMonitor) do
- for size = 1.5,0.5,-0.5 do
- local monX,monY
- if device.type == "direct" then
- peripheral.call(device.side,"setTextScale",size)
- monX,monY = peripheral.call(device.side,"getSize")
- elseif device.type == "wire" then
- peripheral.call(device.modemSide,"callRemote",device.deviceID,"setTextScale",size)
- monX,monY = peripheral.call(device.modemSide,"callRemote",device.deviceID,"getSize")
- end
- if monX >= termX and monY >= termY then
- table.insert(tPassed[device.type],device)
- break
- end
- end
- end
- local tOut = {}
- print("Running pack process")
- for _,item in pairs(tFunctions) do
- local tempFunction = function()
- return function(...)
- for k,v in pairs(tPassed.direct) do
- peripheral.call(v.side,item,...)
- end
- for k,v in pairs(tPassed.wire) do
- peripheral.call(v.modemSide,"callRemote",v.deviceID,item,...)
- end
- return term.native[item](...)
- end
- end
- tOut[item] = tempFunction()
- end
- return tOut
- end
- local tArg = {...}
- if tArg[1] then
- term.redirect()
- else
- local newTerm = connect(grabScreens())
- term.redirect(newTerm)
- term.clear()
- term.setCursorPos(1,1)
- term.write("test")
- os.pullEvent()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement