Jump to content




While true do error with normal computer


  • You cannot reply to this topic
7 replies to this topic

#1 Bye.

  • Members
  • 59 posts

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 by Checco2212, 05 January 2016 - 11:41 AM.


#2 Lignum

  • Members
  • 558 posts

Posted 05 January 2016 - 11:55 AM

Only advanced computers and monitors can detect mouse clicks. So yes, this is normal.

#3 Bye.

  • Members
  • 59 posts

Posted 05 January 2016 - 12:08 PM

View PostLignum, on 05 January 2016 - 11:55 AM, said:

Only advanced computers and monitors can detect mouse clicks. So yes, this is normal.
Thank you!

#4 Lignum

  • Members
  • 558 posts

Posted 05 January 2016 - 12:11 PM

You're welcome!

#5 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

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 by Sewbacca, 08 January 2016 - 05:45 PM.


#6 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 08 January 2016 - 05:54 PM

View PostSewbacca, on 08 January 2016 - 05:42 PM, said:

You have to add a local before you declare multiple variables:

This is wrong.

#7 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 08 January 2016 - 08:38 PM

View PostKingofGamesYami, on 08 January 2016 - 05:54 PM, said:

View PostSewbacca, on 08 January 2016 - 05:42 PM, said:

You have to add a local before you declare multiple variables:

This is wrong.

Really? Thanks!

#8 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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...i/ScopeTutorial





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users