Jump to content




What am I making wrong?


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

#1 rdmGAMER

  • Members
  • 60 posts
  • LocationGermany

Posted 26 June 2016 - 02:07 PM

I'm trying to make an OS, but the events that I code aren't working. Why? Please help.

Here is one part of the event codes :

while true do
local event, X, Y = os.pullEvent("mouse_click")
if X==4 and Y==6 then
login()
break
elseif X==4 and Y==8 then
register()
break
end
end


#2 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 26 June 2016 - 02:12 PM

You're forgetting to parse for the mouse button pressed...
local event, button, X, Y = os.pullEvent("mouse_click")


#3 rdmGAMER

  • Members
  • 60 posts
  • LocationGermany

Posted 26 June 2016 - 02:13 PM

EDIT : I tried it out and it isn't working :unsure:

Edited by erik0004, 26 June 2016 - 02:16 PM.


#4 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 26 June 2016 - 02:37 PM

Please post the code you tried.

#5 rdmGAMER

  • Members
  • 60 posts
  • LocationGermany

Posted 26 June 2016 - 02:38 PM

Here it is :

Spoiler

(Its long so I put it in a spoiler)

Edited by erik0004, 26 June 2016 - 02:40 PM.


#6 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 26 June 2016 - 02:45 PM

The reason it's not working is because you're capturing the button in X, X is being captured in Y, and Y is being captured in button. The order in which the information is returned doesn't change, you must order your variables correctly.

This is your line:
local event, X, Y, button = os.pullEvent("mouse_click")

and this is what I suggested:
local event, button, X, Y = os.pullEvent("mouse_click")

Do you see the difference?

#7 rdmGAMER

  • Members
  • 60 posts
  • LocationGermany

Posted 26 June 2016 - 02:53 PM

Okay... I already programmed 2 OS' and I never had that problem. I also had
local event , X, Y, button = os.pullEvent("mouse_click")
in exactly this order. I don't understand why it is now so

But thank you





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users