Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function stub() return end
- local function stubonearg(a) return end
- function getTerm(sSide)
- local printer = peripheral.wrap(sSide)
- local onPage = false
- if not printer then error("PrintermAPI: No printer on side "..sSide) end
- local tx,ty = 1,1
- local function checkStatus()
- if printer.getPaperLevel()==0 then error("PrintermAPI: No paper in the printer!",0) end
- if printer.getInkLevel()==0 then error("PrintermAPI: No ink in the printer",0) end
- end
- checkStatus()
- local ret = {}
- for k,v in pairs(printer) do
- ret[k] = v
- end
- ret.newPage = function()
- onPage = true
- printer.newPage()
- end
- ret.endPage = function()
- onPage = false
- printer.endPage()
- end
- ret.write = function(s)
- if not onPage then
- ret.newPage()
- end
- checkStatus()
- printer.write(s)
- tx,ty = printer.getCursorPos()
- end
- ret.blit = function(s,tc,bc)
- ret.write(s)
- end
- ret.clear = stub
- ret.clearLine = stub
- ret.setCursorBlink = stub
- ret.isColor = function() return false end
- ret.getSize = printer.getPageSize
- ret.scroll = stubonearg
- ret.setTextColor = stubonearg
- ret.getTextColor = function() return colors.black end
- ret.setBackgroundColor = stubonearg
- ret.getBackgroundColor = function() return colors.white end
- ret.setTextColour = stubonearg
- ret.getTextColour = function() return colors.black end
- ret.setBackgroundColour = stubonearg
- ret.getBackgroundColour = function() return colors.white end
- return ret
- end
Advertisement
Add Comment
Please, Sign In to add comment