Difference between revisions of "Printer.setCursorPos"
From ComputerCraft Wiki
(frjkdghnuirjkd) |
MKlegoman357 (Talk | contribs) m (Expanded) |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | {{lowercase}} | |
| + | {{Function | ||
| + | |name=''printer''.setCursorPos | ||
| + | |args={{type|number}} x, {{type|number}} y | ||
| + | |returns={{type|nil}} | ||
| + | |api=printer | ||
| + | |addon=ComputerCraft | ||
| + | |desc=Sets the cursor position on the page, works the same way as [[term.setCursorPos]](). | ||
| + | |examples= | ||
| + | {{Example | ||
| + | |desc=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 (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() |