Jump to content




[SOLVED] odd eT,x,y os.pullEvent() bug? (as long as x is same as statement requests, it's fine, y is irrelevant.)


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

#1 pielover88888

  • Members
  • 66 posts
  • LocationIn a library that's in a village, huddling my advanced computer as zombies bang on the door.

Posted 12 January 2013 - 10:06 AM

Hello everybody,

I have this..odd, to say the least, problem in my code..
here's the program: http://pastebin.com/hAm0LKJH (lol, ham.. mm..).

Try clicking on x one, any y for x one, and once you do that, x two, and have any y. I, temporarily, put a spacebar-to-exit, if your spacebar returns 57 it should work.

It miiiight exit to the shell if you hit any coordinate with an x of three, but that proved unreliable so I put the spacebar-to-exit "feature".

#2 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 12 January 2013 - 10:12 AM

The "mouse_click" event also returns the mouse buttons that's being pressed as the second value (1 for left click, 2 for right click and 3 for the middle mouse button, I believe). So instead of:
eT,x,y = os.pullEvent()
use this:
eT,button,x,y = os.pullEvent()
So 'button' will be 1 on left click. Don't forget to change:
if eT == "key" and x == 57 then break end
to:
if eT == "key" and button == 57 then break end
as well then.

Edit: Stuff like this is also on the wiki. :)

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 12 January 2013 - 10:15 AM

It's not "mouse_click", x, y. It's "mouse_click", button, x, y. Try using the correct return values for your comparison.

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 12 January 2013 - 11:10 AM

 Orwell, on 12 January 2013 - 10:12 AM, said:

So 'button' will be 1 on left click. Don't forget to change:
if eT == "key" and x == 57 then break end
to:
if eT == "key" and button == 57 then break end
as well then.
I think you mean
if eT == "key" and button == 1 and x == 57 then break end
Button would never be 57, as you said it's 1, 2 or 3

#5 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 12 January 2013 - 11:11 AM

 TheOriginalBIT, on 12 January 2013 - 11:10 AM, said:

 Orwell, on 12 January 2013 - 10:12 AM, said:

So 'button' will be 1 on left click. Don't forget to change:
if eT == "key" and x == 57 then break end
to:
if eT == "key" and button == 57 then break end
as well then.
I think you mean
if eT == "key" and button == 1 and x == 57 then break end
Button would never be 57, as you said it's 1, 2 or 3
It would when the event was a key event O.o .

#6 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 12 January 2013 - 11:17 AM

 Orwell, on 12 January 2013 - 11:11 AM, said:

 TheOriginalBIT, on 12 January 2013 - 11:10 AM, said:

 Orwell, on 12 January 2013 - 10:12 AM, said:

So 'button' will be 1 on left click. Don't forget to change:
if eT == "key" and x == 57 then break end
to:
if eT == "key" and button == 57 then break end
as well then.
I think you mean
if eT == "key" and button == 1 and x == 57 then break end
Button would never be 57, as you said it's 1, 2 or 3
It would when the event was a key event O.o .

This made me laugh. xD TOB probably didn't check the event :P/>

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 12 January 2013 - 11:20 AM

 remiX, on 12 January 2013 - 11:17 AM, said:

 Orwell, on 12 January 2013 - 11:11 AM, said:

 TheOriginalBIT, on 12 January 2013 - 11:10 AM, said:

 Orwell, on 12 January 2013 - 10:12 AM, said:

So 'button' will be 1 on left click. Don't forget to change:
if eT == "key" and x == 57 then break end
to:
if eT == "key" and button == 57 then break end
as well then.
I think you mean
if eT == "key" and button == 1 and x == 57 then break end
Button would never be 57, as you said it's 1, 2 or 3
It would when the event was a key event O.o .

This made me laugh. xD TOB probably didn't check the event :P/>/>
Ooohhhh oops haha... thats what I get for reading it when I'm tired... lol

#8 pielover88888

  • Members
  • 66 posts
  • LocationIn a library that's in a village, huddling my advanced computer as zombies bang on the door.

Posted 12 January 2013 - 12:24 PM

Quite a conversation I stirred up :o but, thanks lol!
The if eT == "key" and x == 57 then break end, was so if you hit the spacebar, it quits.. which I will have to adjust once I edit eT, x, y = os.pullEvent() to eT, button, x , y = os.pullEvent()

Thanks guys! It works now! (In the case you want the corrected code, with a term.setCursorPos(1,9), a term.clear(), and a paintutils make black cell so it won't be fully blue, to happen upon spacebar, and a bug fix here: http://pastebin.com/jUvfw0uC )

EDIT: ugh, nevermind, the one bug fix was supposed to be if push == "true" then allow "INDEED" to be printed, but it does it with or without that. ugh.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users