Difference between revisions of "Printer.getInkLevel"

From ComputerCraft Wiki
Jump to: navigation, search
(corrected link for API)
m (Expanded)
 
Line 1: Line 1:
 
{{lowercase}}
 
{{lowercase}}
 
{{Function
 
{{Function
|name=printer.getInkLevel
+
|name=''printer''.getInkLevel
|returns={{type|number}} Amount of ink in printer.
+
|returns={{type|number}} amount of ink in the printer.
 
|api=printer
 
|api=printer
 
|addon=ComputerCraft
 
|addon=ComputerCraft
|desc=Tells you how much ink is in the printer.
+
|desc=Returns the amount of ink in the printer's ink slot.
 
|examples=
 
|examples=
 
{{Example
 
{{Example
|desc=Prints true if there's ink in the printer.
+
|desc=Prints how much ink there is in the printer (assuming there are 6 ink sacs in the printer).
|code=print(printer.getInkLevel() > 0)
+
|code= local printer = [[peripheral.wrap]]("left")
|output=true if there is ink in the printer, false if there isn't ink.
+
local inkAmount = printer.getInkLevel()
 +
 +
print("There is/are " .. inkAmount .. " dye(s) in the printer.")
 +
|output=There is/are 6 dye(s) in the printer.
 
}}
 
}}
 
}}
 
}}
  
 
[[Category:Lua_Core_Functions]]
 
[[Category:Lua_Core_Functions]]

Latest revision as of 18:36, 9 April 2014


Grid Redstone.png  Function printer.getInkLevel
Returns the amount of ink in the printer's ink slot.
Syntax printer.getInkLevel()
Returns number amount of ink in the printer.
Part of ComputerCraft
API printer

Examples

Grid paper.png  Example
Prints how much ink there is in the printer (assuming there are 6 ink sacs in the printer).
Code
local printer = peripheral.wrap("left")
local inkAmount = printer.getInkLevel()

print("There is/are " .. inkAmount .. " dye(s) in the printer.")
Output There is/are 6 dye(s) in the printer.