63 posts
Location
In 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".
1054 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. :)/>
8543 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.
7508 posts
Location
Australia
Posted 12 January 2013 - 11:10 AM
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
1054 posts
Posted 12 January 2013 - 11:11 AM
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 .
2088 posts
Location
South Africa
Posted 12 January 2013 - 11:17 AM
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/>/>
7508 posts
Location
Australia
Posted 12 January 2013 - 11:20 AM
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
63 posts
Location
In 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.