Posted 02 November 2012 - 11:31 PM
I've been writing a script to run printers.
Currently you need to put the lines within the program, but i will update this later so that you can enter them at run-time.
Remember, there is a maximum of 6 pages that can be printed at once.
File: print
Currently you need to put the lines within the program, but i will update this later so that you can enter them at run-time.
Remember, there is a maximum of 6 pages that can be printed at once.
Changelog:
- V1.1:
- you can set the number of the page that printing can start on
- print <side> <pagetostarton> <title>
- V1.1 Bugs:
- Sometimes, certain pages may be duplicated, this may happen when you print from numbers higher than 1
- e.g: 7,8,9,10,11,12
- Confirmed at 7 & 12
- V1.0:
- Initial Release
- Ability to print as many pages as wanted, however has a max of 6
File: print
function printUsage()
print( "Usage: print <side> <pagetostart> <title>" )
return
end
local tArgs = { ... }
if #tArgs < 3 then
printUsage()
return
end
local pages = { {"Title: Page 1","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 2","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 3","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 4","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 5","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 6","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 7","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 8","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 9","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 10","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 11","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 12","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 13","Line1","Line2","Line3","Line4","Line5"},
{"Title: Page 14","Line1","Line2","Line3","Line4","Line5"}};
local sSide = tArgs[1]
if peripheral.getType( sSide ) ~= "printer" then
print( "No printer on "..sSide.." side" )
return
end
local printer = peripheral.wrap( sSide )
title = ""
yCord = 0
for i=3, table.getn(tArgs) do
title = title ..tArgs[i] .." "
end
for i = tArgs[2], table.getn(pages) do
if printer.getInkLevel() < 1 then
print( "Please Refil Ink!" )
end
if printer.getPaperLevel() < 1 then
print( "Please Refil Paper!" )
end
if printer.getPaperLevel() > 0 then
if printer.getInkLevel() > 0 then
if printer.newPage() then
printer.setPageTitle( title )
for n = 0, table.getn(pages[i]) do
printer.setCursorPos( 1, yCord )
printer.write( pages[i][n] )
yCord = yCord + 1
end
printer.endPage()
yCord = 0
end
end
end
end