Difference between revisions of "Printer.setCursorPos"
From ComputerCraft Wiki
MathManiac0 (Talk | contribs) (Added Page) |
MKlegoman357 (Talk | contribs) m (Expanded) |
||
| (6 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
{{lowercase}} | {{lowercase}} | ||
{{Function | {{Function | ||
| − | |name=printer. | + | |name=''printer''.setCursorPos |
| − | |args= | + | |args={{type|number}} x, {{type|number}} y |
| − | |returns= | + | |returns={{type|nil}} |
| − | |api= | + | |api=printer |
|addon=ComputerCraft | |addon=ComputerCraft | ||
| − | |desc=Sets the position | + | |desc=Sets the cursor position on the page, works the same way as [[term.setCursorPos]](). |
|examples= | |examples= | ||
{{Example | {{Example | ||
| − | |desc=Sets the cursor | + | |desc=Sets the cursor position to the center of the paper and prints "X". |
| − | |code=printer. | + | |code= local printer = [[peripheral.wrap]]("left") |
| − | | | + | |
| + | [[printer.newPage]]() | ||
| + | |||
| + | local width, height = [[printer.getPageSize]]() | ||
| + | |||
| + | printer.setCursorPos([[Math (API)|math]].floor(width/2), [[Math (API)|math]].floor(height/2)) | ||
| + | [[printer.write]]("X") | ||
| + | |||
| + | [[printer.endPage]]() | ||
}} | }} | ||
}} | }} | ||
| + | |||
| + | [[Category:Lua_Core_Functions]] | ||
Latest revision as of 18:58, 9 April 2014
| Sets the cursor position on the page, works the same way as term.setCursorPos(). | |
| Syntax | printer.setCursorPos(number x, number y) |
| Returns | nil |
| Part of | ComputerCraft |
| API | printer |
Examples
| Sets the cursor position to the center of the paper and prints "X". | |
| Code |
local printer = peripheral.wrap("left") printer.newPage() local width, height = printer.getPageSize() printer.setCursorPos(math.floor(width/2), math.floor(height/2)) printer.write("X") printer.endPage() |