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

Usign os.pullEvent for mouse clicks

Started by willwac, 06 December 2013 - 05:43 PM
willwac #1
Posted 06 December 2013 - 06:43 PM
I can't seem to get mouse clicking to work!
here is the code:

while event ~= "mouse_click" do
  local event, button, x, y = os.pullEvent()
end

I may be going about this all wrong, but we will see…
Bomb Bloke #2
Posted 06 December 2013 - 07:01 PM
You're declaring your variables as local to the inside of the "while" loop, meaning that they reset each time it iterates. Try:

local event, button, x, y
while event ~= "mouse_click" do
  event, button, x, y = os.pullEvent()
end
willwac #3
Posted 06 December 2013 - 07:27 PM
Oh, thanks