Difference between revisions of "Mouse click (event)"
From ComputerCraft Wiki
m (changed os.pullEvent to os.pullEvent) |
(better code example, also better coding habits) |
||
Line 10: | Line 10: | ||
|code= | |code= | ||
while true do | while true do | ||
− | event, button, xPos, yPos = [[os.pullEvent]]("[[mouse_click_(event)|mouse_click]]") | + | local event, button, xPos, yPos = [[os.pullEvent]]("[[mouse_click_(event)|mouse_click]]") |
− | [[print]]( | + | [[print]]("Mouse button clicked: ", button, " => Click Position X: ", xPos, " => Click Position Y: ", yPos) |
− | + | ||
− | + | ||
end | end | ||
|output=The button that was pressed, followed by the X and Y position of the event. | |output=The button that was pressed, followed by the X and Y position of the event. | ||
}} | }} | ||
}} | }} |
Revision as of 01:50, 20 November 2013
Examples
Example | |
Print the button and the co-ordinates of every mouse click we receive a mouse_click event. | |
Code |
while true do local event, button, xPos, yPos = os.pullEvent("mouse_click") print("Mouse button clicked: ", button, " => Click Position X: ", xPos, " => Click Position Y: ", yPos) end |
Output | The button that was pressed, followed by the X and Y position of the event. |