Posted 19 October 2012 - 01:13 PM
Hi all
here is my easy printer tutorial:
first we need to connect to the printer.
the printer is on the right of the computer
we also have to know how much ink and paper is left in the printer.
then we check if we have enough ink and paper to print.
now we start editing our page.
if you want more lines we need a loop
that's it for today(maybe)
if you have any questions post them below.
if you want my coding expertise feel free to contact me. I know allot more than i am showing here.
sorry for my bad English i am dutch
here is my easy printer tutorial:
first we need to connect to the printer.
the printer is on the right of the computer
p = peripheral.wrap("right") --you could change the side to what ever you like
we also have to know how much ink and paper is left in the printer.
p = peripheral.wrap("right") --you could change the side to what ever you like
ink = p.getInkLevel()
paper = p.getPaperLevel()
then we check if we have enough ink and paper to print.
p = peripheral.wrap("right") --you could change the side to what ever you like
ink = p.getInkLevel()
paper = p.getPaperLevel()
if ink > 0 and paper > 0 then
--code
else
print("fill the printer with ink and paper please")
end
now we start editing our page.
p = peripheral.wrap("right") --you could change the side to what ever you like
ink = p.getInkLevel()
paper = p.getPaperLevel()
if ink > 0 and paper > 0 then
p.newPage() --make's you edit the page
print("your text:")
input = io.read() --reads your input
p.write(input) --writes your input to the page
p.endPage() --prints the page
else
print("fill the printer with ink and paper please")
end
now we have printed 1 line to the pageif you want more lines we need a loop
p = peripheral.wrap("right") --you could change the side to what ever you like
ink = p.getInkLevel() --get ink level from printer
paper = p.getPaperLevel() --get paper level from printer
if ink > 0 and paper > 0 then
line = 1 --sets line to 1
while true do --main loop
input = io.read() --reads your input
if input == "exit()" then --if input is exit() it will stop adding text to the file
p.endPage()
break
else
print("text for line " ..line..":")
p.write(input) --writes the input to to paper
line = line + 1 --adds 1 to line
p.setCursorPos(1,line) --moves the cursor(position where you are going to write) 1 down
end
end
else
print("fill the printer with ink and paper please")
end
that's it for today(maybe)
if you have any questions post them below.
if you want my coding expertise feel free to contact me. I know allot more than i am showing here.
sorry for my bad English i am dutch