Advertisement
DaikiKaminari

print_page

Apr 4th, 2020
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. local function getPrinterPeripheral()
  2.     printer = peripheral.find("printer")
  3.     if printer == nil then
  4.         error("Error : Printer not found")
  5.     end
  6.     return printer
  7. end
  8.  
  9. local function printPage(printer, title, inputFile)
  10.     local f = fs.open(inputFile, "r")
  11.     if f == nil then
  12.         error("File " .. inputFile .. " not found")
  13.     end
  14.  
  15.     printer.newPage()
  16.     printer.setPageTitle(title)
  17.     local i = 1
  18.     local line = f.readLine()
  19.     while line ~= nil do
  20.         printer.setCursorPos(1, i)
  21.         printer.write(line)
  22.         i = i + 1
  23.         line = f.readLine()
  24.     end
  25.     f.close()
  26.     printer.endPage()
  27. end
  28.  
  29. local function main()
  30.     printer = getPrinterPeripheral()
  31.     while true do
  32.         printPage(printer, "Privatise ton enderchest", "text")
  33.         sleep(5)
  34.     end
  35. end
  36.  
  37. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement