This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Crowdy199's profile picture

click

Started by Crowdy199, 21 November 2012 - 02:30 PM
Crowdy199 #1
Posted 21 November 2012 - 03:30 PM
how do i make it run code by clicking things i no its possilbe with cc 1.4.1
remiX #2
Posted 21 November 2012 - 11:20 PM

while true do
	e, p1, p2, p3 = os.PullEvent()
	if e == "mouse_click" then
	   -- if mouse click
	elseif e == "mouse_drag" then
	   -- if mouse drag
	end
end
p1 is 1 or 2, left or right click - I think
Crowdy199 #3
Posted 22 November 2012 - 01:15 AM
i am still confused
remiX #4
Posted 22 November 2012 - 01:36 AM
I can't find a website for this but I got this off the CC Wiki

while true do
    e, p1, p2, p3 = os.PullEvent()
    if e == "mouse_click" then
        -- if mouse click
        -- p1 is which button (left or right)
        -- 1 is left
        -- 2 is right
    elseif e == "mouse_drag" then
        -- if mouse drag
        -- p1 is X co-ord
        -- p2 is Y co-ord
    elseif e == "mouse_scroll" then
        -- if you use the scroll button
        -- p1 is up or down (-1 for up, 1 for down
        -- p2 is X co-ord
        -- p3 is Y co-ord
    end
end
Lyqyd #5
Posted 22 November 2012 - 04:29 AM
This is not possible with 1.41, only 1.45 or later, and only on advanced computers.