Difference between revisions of "Mouse click (event)"
From ComputerCraft Wiki
(Fixed that for ya) |
(fixed again) |
||
Line 12: | Line 12: | ||
while true do | while true do | ||
event, button, xPos, yPos = os.pullEvent("[[mouse_click_(event)|mouse_click]]") | event, button, xPos, yPos = os.pullEvent("[[mouse_click_(event)|mouse_click]]") | ||
− | [[print]]( | + | [[print]](event .. " => " .. tostring(button) .. ": " .. [[tostring]](button) .. ", " .. |
"X: " .. [[tostring]](xPos) .. ", " .. | "X: " .. [[tostring]](xPos) .. ", " .. | ||
"Y: " .. [[tostring]](yPos)) | "Y: " .. [[tostring]](yPos)) |
Revision as of 09:20, 7 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 event, button, xPos, yPos = os.pullEvent("mouse_click") print(event .. " => " .. tostring(button) .. ": " .. 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. |