Difference between revisions of "Mouse click (event)"
From ComputerCraft Wiki
(Included an example.) |
m (Corrected mistake where I forgot to pullEvent("mouse_click"). Hurr.) |
||
Line 10: | Line 10: | ||
|code= | |code= | ||
while true do | while true do | ||
− | button, xPos, yPos = os.pullEvent() | + | button, xPos, yPos = os.pullEvent("[[mouse_click_(event)|mouse_click]]") |
[[print]]("mouse_click: " .. [[tostring]](button) .. ", " .. | [[print]]("mouse_click: " .. [[tostring]](button) .. ", " .. | ||
"X: " .. [[tostring]](xPos) .. ", " .. | "X: " .. [[tostring]](xPos) .. ", " .. |
Revision as of 00:31, 1 December 2012
Examples
Example | |
Print the button and the co-ordinates of every mouse click we receive a mouse_click event. | |
Code |
while true do button, xPos, yPos = os.pullEvent("mouse_click") print("mouse_click: " .. tostring(button) .. ", " .. "X: " .. tostring(xPos) .. ", " .. "Y: " .. tostring(yPos)) end |
Output | The button that was pressed, followed by the X and Y position of the event. |