SHOW:
|
|
- or go back to the newest paste.
| 1 | print("loading basic API...")
| |
| 2 | monitors = {}
| |
| 3 | modems = {}
| |
| 4 | ||
| 5 | function bind(target) | |
| 6 | return peripheral.wrap(target) | |
| 7 | end | |
| 8 | ||
| 9 | function init() | |
| 10 | for k,side in pairs(rs.getSides()) do | |
| 11 | if(peripheral.getType(side) == "monitor") then | |
| 12 | print("found monitor on "..side.." side")
| |
| 13 | table.insert(monitors, bind(side)) | |
| 14 | elseif((peripheral.getType(side) == "modem") and | |
| 15 | (peripheral.call(side,"isWireless")==false))then | |
| 16 | local modem = bind(side) | |
| 17 | print("found modem on "..side.." side")
| |
| 18 | table.insert(modems, modem) | |
| 19 | for n,device in pairs(modem.getNamesRemote()) do | |
| 20 | if(modem.getTypeRemote(device) == "monitor") then | |
| 21 | print("found monitor "..device.." on "..side.." modem")
| |
| 22 | table.insert(monitors, bind(device)) | |
| 23 | end | |
| 24 | end | |
| 25 | end | |
| 26 | end | |
| 27 | end | |
| 28 | ||
| 29 | init() | |
| 30 | ||
| 31 | function checkmon() | |
| 32 | return (monitor==nil) or (monitor["setTextColor"]) | |
| 33 | end | |
| 34 | ||
| 35 | function printmon(monitor, text) | |
| 36 | if(checkmon()) then | |
| 37 | print("monitor missing")
| |
| 38 | else | |
| 39 | monitor.write(text) | |
| 40 | end | |
| 41 | end | |
| 42 | ||
| 43 | function printmon(text) | |
| 44 | for k,monitor in pairs(monitors) do | |
| 45 | printmon(monitor,text) | |
| 46 | end | |
| 47 | end | |
| 48 | ||
| 49 | function printmon(monitor, text,xc,yc) | |
| 50 | if(checkmon()) then | |
| 51 | print("monitor missing")
| |
| 52 | else | |
| 53 | monitor.setCursorPos(xc,yc) | |
| 54 | monitor.write(text) | |
| 55 | end | |
| 56 | end | |
| 57 | ||
| 58 | function printmon(text,xc,yc) | |
| 59 | for k,monitor in pairs(monitors) do | |
| 60 | printmon(monitor,text,xc,yc) | |
| 61 | end | |
| 62 | end | |
| 63 | ||
| 64 | function println(monitor,text) | |
| 65 | if(checkmon()) then | |
| 66 | print("monitor missing")
| |
| 67 | else | |
| 68 | monitor.write(text) | |
| 69 | local xc,yc = monitor.getCursorPos() | |
| 70 | yc = yc+1 | |
| 71 | xc = 1 | |
| 72 | local xs,ys = monitor.getSize() | |
| 73 | if(yc > ys) then monitor.scroll(yc-ys) end | |
| 74 | end | |
| 75 | end | |
| 76 | ||
| 77 | - | function println(text) |
| 77 | + | function printLn(text) |
| 78 | for k,mon in pairs(monitors) do | |
| 79 | println(mon,text) | |
| 80 | end | |
| 81 | end | |
| 82 | print("finished loading!") |