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

While true do error with normal computer

Started by Bye., 05 January 2016 - 10:41 AM
Bye. #1
Posted 05 January 2016 - 11:41 AM
I have a problem with this code


while true do
event, button, x, y =os.pullEvent("mouse_click")
  if x == nil or y == nil then
   cPrint("Invalid Click")
  end
  if x>=2 and x<=16 and y>=5 and y<=7 then
   start()
  break
				end
end

It doesn't work on normal computer.

Is it normal? I'm using Computercraft 1.75 for minecraft 1.7.10

Thank you!
Edited on 05 January 2016 - 10:41 AM
Lignum #2
Posted 05 January 2016 - 11:55 AM
Only advanced computers and monitors can detect mouse clicks. So yes, this is normal.
Bye. #3
Posted 05 January 2016 - 12:08 PM
Only advanced computers and monitors can detect mouse clicks. So yes, this is normal.
Thank you!
Lignum #4
Posted 05 January 2016 - 12:11 PM
You're welcome!
Sewbacca #5
Posted 08 January 2016 - 05:42 PM
You have to add a local before you declare multiple variables:


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

  if x == nil or y == nil then
	cPrint("Invalid Click")
  end

  if x>=2 and x<=16 and y>=5 and y<=7 then
	start()
	break
  end
end

But you need a advanced computer too.
Edited on 08 January 2016 - 04:45 PM
KingofGamesYami #6
Posted 08 January 2016 - 05:54 PM
You have to add a local before you declare multiple variables:

This is wrong.
Sewbacca #7
Posted 08 January 2016 - 08:38 PM
You have to add a local before you declare multiple variables:

This is wrong.

Really? Thanks!
Bomb Bloke #8
Posted 09 January 2016 - 02:31 AM
Well, wrong in that you don't have to do it. In the context the code was written, it would've been good practise to do so anyway.

http://lua-users.org/wiki/ScopeTutorial