This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DannySMc's profile picture

Printer Levels Finder

Started by DannySMc, 19 July 2013 - 06:23 PM
DannySMc #1
Posted 19 July 2013 - 08:23 PM
I have made a program that just simply tells you the printer levels, but I need it to say: "There are (paper_amount) pages left."
But I don't know how to do it:/ Here is my program:

printer = peripheral.wrap("printer_0")
paper = printer.getPaperLevel()
ink = printer.getInkLevel()
print("There are" paper "page(s) left")
print("You have" ink "ink left.")

Help please :)/>
Zudo #2
Posted 20 July 2013 - 01:55 AM
print("There are" .. paper .. "page(s) left")


Use .. to concatenate strings
Zoinky #3
Posted 20 July 2013 - 01:58 AM
You need to concatenate the strings. You can do this simply by adding the concatenation operator "..". So your print lines should be:


print("There are "..paper.." page(s) left")
print("You have "..ink.." ink left.")

EDIT: Ninja'd
MysticT #4
Posted 20 July 2013 - 01:00 PM
Or:

print("There are ", paper, " page(s) left")
print("You have ", ink, " ink left.")
since print accepts any number of arguments, and will print all of them.