This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Klausar's profile picture

Need explanation for mouseclicks

Started by Klausar, 27 October 2012 - 06:04 AM
Klausar #1
Posted 27 October 2012 - 08:04 AM
So I'm trying to make a program, that when you click somewhere, something happens. But I don't get how to do it. If I click at position 5,6 for example I want something to happen, can someone make a example code and explain it?
Luanub #2
Posted 27 October 2012 - 08:08 AM
Use events to caputre where the click took place and use an if statement to check if it was in a location that it needs to do something.

local event, button, mouseX, mouseY = os.pullEvent("mouse_click")
if mouseX == 5 and mouseY == 6 then
--do stuff
end
Klausar #3
Posted 27 October 2012 - 09:54 AM
Thank you good sir!