Difference between revisions of "Printer.setCursorPos"
From ComputerCraft Wiki
MKlegoman357 (Talk | contribs) m (Expanded) |
|||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{lowercase}} | {{lowercase}} | ||
{{Function | {{Function | ||
− | |name=printer.setCursorPos | + | |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
Function printer.setCursorPos | |
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
Example | |
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() |