97 posts
Location
Ohio, USA
Posted 21 May 2013 - 06:40 PM
How can I use the advanced monitors?
event, button, x, y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if x >= 5 and x <= 1 and y <= 1 and y >= 5 then
print("hi")
else
print("no")
end
end
135 posts
Posted 21 May 2013 - 07:27 PM
You figured it out quite good yourself, you make it wait for an event, then you can use the if-then-else statements to figure out what to do with a certain touch. The correct event emitted is "monitor_touch" and not "mouse_click" though.
event, button, x, y = os.pullEvent("monitor_touch")
if x >= 5 and x <= 1 and y <= 1 and y >= 5 then
print("hi")
else
print("no")
end
You do not need to check if the event is a monitor_touch in your code, because you already made it in the os.pullEvent() that the only event it will record, is a monitor_touch. So if there is an event, it
must be the monitor_touch.
97 posts
Location
Ohio, USA
Posted 22 May 2013 - 05:46 PM
Alright, thanks. :)/>
1688 posts
Location
'MURICA
Posted 22 May 2013 - 09:18 PM
I'd like to add that the monitor_touch event returns different parameters from the mouse_click event, as you can only use right-click with the monitor (left-click would destroy it, middle-click would pick it). It actually returns the side that the monitor is on instead of the button, and returns the same x, y coords as the mouse_click event.
event, side, x, y = os.pullEvent("monitor_touch")