Difference between revisions of "Printer.getCursorPos"
From ComputerCraft Wiki
(Corrected API link) |
MKlegoman357 (Talk | contribs) m (Expanded) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
{{lowercase}} | {{lowercase}} | ||
{{Function | {{Function | ||
| − | |name=printer.getCursorPos | + | |name=''printer''.getCursorPos |
| − | |returns={{type|number}} x | + | |returns={{type|number}} x position of the cursor, {{type|number}} y position of the cursor |
|api=printer | |api=printer | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
| − | |desc= | + | |desc=Returns the coordinates of the cursor on the paper, works the same way as [[term.getCursorPos]](). |
|examples= | |examples= | ||
{{Example | {{Example | ||
| − | |desc= | + | |desc=Writes text on the paper and then prints the cursor position. |
| − | |code=local | + | |code= local printer = [[peripheral.wrap]]("left") |
| − | |output=X: | + | |
| + | [[printer.newPage]]() | ||
| + | [[printer.write]]("Hello, World!") | ||
| + | |||
| + | local x, y = printer.getCursorPos() | ||
| + | print("The cursor on the paper is on X: " .. x .. " and Y: " .. y) | ||
| + | |||
| + | [[printer.endPage]]() | ||
| + | |output=The cursor on the paper is on X: 14 and Y: 1 | ||
}} | }} | ||
}} | }} | ||
[[Category:Lua_Core_Functions]] | [[Category:Lua_Core_Functions]] | ||
Latest revision as of 18:42, 9 April 2014
| Returns the coordinates of the cursor on the paper, works the same way as term.getCursorPos(). | |
| Syntax | printer.getCursorPos() |
| Returns | number x position of the cursor, number y position of the cursor |
| Part of | ComputerCraft |
| API | printer |
Examples
| Writes text on the paper and then prints the cursor position. | |
| Code |
local printer = peripheral.wrap("left") printer.newPage() printer.write("Hello, World!") local x, y = printer.getCursorPos() print("The cursor on the paper is on X: " .. x .. " and Y: " .. y) printer.endPage() |
| Output | The cursor on the paper is on X: 14 and Y: 1 |