2 posts
Posted 23 May 2017 - 09:06 AM
I work on a program which allows to choose one Printer in a network with multiple printers.
Works fine til the print process, there are no errors. Any Ideas?
--Beta Program for Network Printing for ComputerCraft
print("Choose Printer 10-13")
Nr=read()
local Prin = "printer_"
local printer = Prin..Nr
print(" "..printer.." ")
sleep(2)
local modem = printer
printer.newPage()
printer.write("Test")
printer.endPage()
Edited on 23 May 2017 - 12:36 PM
2 posts
Posted 23 May 2017 - 12:05 PM
Found the sulution myself
--Beta Program for Network Printing for ComputerCraft
print("Choose Printer 10-13") -- 10-13 as example
nr=read()
local prin = "printer_"
local pri = prin..nr
printer = peripheral.wrap(""..pri.."")
printer.newPage()
printer.write("Test")
printer.endPage()
term.clear()
print("Printing finished")
sleep(2)
Any suggetions how to make this better and create a code which allows me to define the printet text as variable with a automatic line switch ?
Like this:
local msg = "Hello"
letters = string.len(msg)
msg:len()
if letters =< 16
printer.setCusorPos(1,2+1)
end
Sometihng like this
8 posts
Location
United States
Posted 11 June 2017 - 04:56 PM
I think you're over-complicating. Can you not just wrap individual printers on a wired network in individual variables:
pZero=peripheral.wrap("printer_0")
pOne=peripheral.wrap("printer_1")
Then do the print functions:
pZero.newPage()
pZero.write("This is printer_0")
pZero.endPage()
pOne.newPage()
pOne.write("This is printer_1")
pOne.endPage()
EDIT: Also rather than doing:
print(" "..printer.." ")
It's more efficient to do:
print(printer)
You don't need to concatenate a string with a space unless you were experimenting with screen size or something.
If this isn't what you were looking for sorry I don't understand lol
Edited on 11 June 2017 - 03:02 PM