Posted 25 January 2013 - 07:00 PM
I'm doing a printer program that let's you choose the amount of lines and then you write what you want. I know I have 25 Chars per line and 21 lines.
The problem is that it only prints one page at a time. So, I wanted some help to make it print multiple copies (determined by the user).
Basically this is the program.
The problem is that it only prints one page at a time. So, I wanted some help to make it print multiple copies (determined by the user).
Basically this is the program.
Spoiler
term.clear()
term.setCursorPos(1,1)
local printer
for _,side in pairs(redstone.getSides()) do
if peripheral.getType(side)=="printer" then
printer=peripheral.wrap(side)
break
end
end
if printer==nil then
error("Connect a printer.")
end
local ink=printer.getInkLevel()
local paper=printer.getPaperLevel()
print("Ink levels: ")
term.setCursorPos(19,1)
print(ink)
print("Paper levels: ")
term.setCursorPos(19,2)
print(paper)
if ink==0 then
print("Needs Ink.")
end
if paper==0 then
print("Put some Paper.")
end
while printer.getInkLevel() == 0 do
os.sleep(.5)
end
while printer.getPaperLevel() == 0 do
os.sleep(.5)
end
printer.newPage()
print("Insert Title.")
local title = read()
printer.setPageTitle(title)
print("Amount of Lines. (1 to 21)")
local lines = read()
local temp = lines
lines = tonumber(lines)
while true do
if (lines < 1) or (lines > 21) then
print("Choose between 1 a 21")
else
break
end
end
print("Write your Document.")
print("NOTA: Max 25 characters per line.")
local h = 0
while h < lines do
h = h + 1
local doc = read()
printer.setCursorPos(1,h)
printer.write(doc)
end
printer.endPage()
term.clear()
term.setCursorPos(1,1)