Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("loading basic API...")
- monitors = {}
- modems = {}
- function bind(target)
- return peripheral.wrap(target)
- end
- function init()
- for k,side in pairs(rs.getSides()) do
- if(peripheral.getType(side) == "monitor") then
- print("found monitor on "..side.." side")
- table.insert(monitors, bind(side))
- elseif((peripheral.getType(side) == "modem") and
- (peripheral.call(side,"isWireless")==false))then
- local modem = bind(side)
- print("found modem on "..side.." side")
- table.insert(modems, modem)
- for n,device in pairs(modem.getNamesRemote()) do
- if(modem.getTypeRemote(device) == "monitor") then
- print("found monitor "..device.." on "..side.." modem")
- table.insert(monitors, bind(device))
- end
- end
- end
- end
- end
- init()
- function checkmon()
- return (monitor==nil) or (monitor["setTextColor"])
- end
- function printmon(monitor, text)
- if(checkmon()) then
- print("monitor missing")
- else
- monitor.write(text)
- end
- end
- function printmon(text)
- for k,monitor in pairs(monitors) do
- printmon(monitor,text)
- end
- end
- function printmon(monitor, text,xc,yc)
- if(checkmon()) then
- print("monitor missing")
- else
- monitor.setCursorPos(xc,yc)
- monitor.write(text)
- end
- end
- function printmon(text,xc,yc)
- for k,monitor in pairs(monitors) do
- printmon(monitor,text,xc,yc)
- end
- end
- function println(monitor,text)
- if(checkmon()) then
- print("monitor missing")
- else
- monitor.write(text)
- local xc,yc = monitor.getCursorPos()
- yc = yc+1
- xc = 1
- local xs,ys = monitor.getSize()
- if(yc > ys) then monitor.scroll(yc-ys) end
- end
- end
- function printLn(text)
- for k,mon in pairs(monitors) do
- println(mon,text)
- end
- end
- print("finished loading!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement