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

Click between lines

Started by svdragster, 14 April 2013 - 07:06 AM
svdragster #1
Posted 14 April 2013 - 09:06 AM

local done = false
while not done do
	local event, x, y = os.pullEvent("mouse_click")
	if (x >= 14) and (x <= 20) and ((y <= 2) and (y >= 4)) then
	 play()
	 done = true
	end
end

Doesn't work. What now?
SuicidalSTDz #2
Posted 14 April 2013 - 09:28 AM
Done is false. You are using a double negative, the loop never occurs..
remiX #3
Posted 14 April 2013 - 09:30 AM
Well…
y = 4 
Your if statement of the y values is saying this:
If y is 2 or LESS AND y is 4 or MORE then continue

Which isn't possible :P/>
If you wanted it to be if y is 3, use and y == 3.

Also brackets aren't required for that if :)Edit: wow when I type the y parts of his if statement not the full thing comes out. I'm getting so annoyed with this -_-Edited it like 6 times with no success
SuicidalSTDz #4
Posted 14 April 2013 - 09:33 AM
You also miss the button arg for mouse_click so x will always be -1 or 1

local event, button,x,y = os.pullEvent("mouse_click")
remiX #5
Posted 14 April 2013 - 09:38 AM
Done is false. You are using a double negative, the loop never occurs..

No.
While not done do
Is the same as
While done == false do

And yeah you missed the button argument :]
SuicidalSTDz #6
Posted 14 April 2013 - 09:41 AM
Done is false. You are using a double negative, the loop never occurs..

No.
Ok, I didn't see the not part. *stupid phone*
svdragster #7
Posted 14 April 2013 - 09:45 AM
So how else can I make a huge clickable button? ^^
Btw I'm using the brackets just to read it better
remiX #8
Posted 14 April 2013 - 09:46 AM
Done is false. You are using a double negative, the loop never occurs..

No.
Ok, I didn't see the not part. *stupid phone*

O_o then where did you get the double negative explanation from?Yeah phones on these forums are a pain!

Edit: try changing the signs of where your y values to the oppisite. < To > and > to < and it should work for the first button
Engineer #9
Posted 14 April 2013 - 09:49 AM
Spoiler
So how else can I make a huge clickable button? ^^
Btw I'm using the brackets just to read it better

I have made a tutorial on this: http://www.computercraft.info/forums2/index.php?/topic/11046-clickable-buttons-in-cc/

I love legal advertisement :P/>
SuicidalSTDz #10
Posted 14 April 2013 - 09:49 AM
Done is false. You are using a double negative, the loop never occurs..

No.
Ok, I didn't see the not part. *stupid phone*

O_o then where did you get the double negative explanation from?Yeah phones on these forums are a pain!
hmm, I guess it wouldn't be a double negative. What would the opposite be? :P/>
svdragster #11
Posted 14 April 2013 - 09:56 AM

(y <= 2) and (y >= 4)

Finally understood that …. I always mix them


Correct one:

(y >= 2) and (y <= 4)

God dangit
svdragster #12
Posted 14 April 2013 - 09:57 AM
Spoiler
So how else can I make a huge clickable button? ^^
Btw I'm using the brackets just to read it better

I have made a tutorial on this: http://www.computerc...-buttons-in-cc/

I love legal advertisement :P/>

Guess where I always look stuff like this up :P/>
I used a tutorial like yours, but it didn't work so I posted it here >.<
Engineer #13
Posted 14 April 2013 - 10:03 AM
I see what you did wrong! :o/>
But I see remiX have answered it already:
Edit: try changing the signs of where your y values to the oppisite. < To > and > to < and it should work for the first button

That is the solution :P/>
svdragster #14
Posted 14 April 2013 - 10:10 AM
Yep :P/>
But I just understood it right now xD