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

How to parse a right click in computercraft?

Started by Endergreen117, 27 November 2014 - 09:24 PM
Endergreen117 #1
Posted 27 November 2014 - 10:24 PM
I'm working on an OS and I have a piece of code that parses input from the user and I can't figure out how to tell the difference between a left- and right-click. This is my code so far:



while true do
local event, button, X, Y = os.pullEventRaw()
if slc == 0 then
if event == "mouse_click" then
if X >= 2 and X <= 4 and Y == 1 and button == 1 then
term.clear ()

elseif X >= 5 and X <= 8 and Y >= 17 and Y <= 19 and button == 1 then
shell.run ("/Falchion/Prg/quest.FEF")

elseif X >= 10 and X <= 14 and Y >= 17 and Y <= 19 and button == 1 then
shell.run ("/Falchion/Prg/Sketch.FEF")

elseif X >= 15 and X <= 19 and Y >= 17 and Y <= 19 and button == 1 then
shell.run ("/Falchion/Prg/ink.FEF")

elseif X >= 20 and X <= 24 and Y >= 17 and Y <= 19 and button == 1 then
shell.run ("/Falchion/Prg/table.FEF")

elseif X == 50 and Y == 1 and button == 1 then
prompt (shutdown)

elseif X == 50 and Y == 1 and button == 2 then -- I took a guess, but that didn't work.
prompt (powMenu)

else drawGUI ()

end

end

end

end


Any help would be appreciated. Thank you.
Lyqyd #2
Posted 27 November 2014 - 10:28 PM
Yep. That's how you do it. What made you think it didn't work?
Exerro #3
Posted 27 November 2014 - 10:44 PM
You're passing in a nil variable to the function I think.
Endergreen117 #4
Posted 28 November 2014 - 12:28 AM
Yep. That's how you do it. What made you think it didn't work?

It would do the same thing as if I had left-clicked it.

You're passing in a nil variable to the function I think.

I actually am passing a nil argument, But I was expecting it to do nothing or return an error, not do the same thing as that which happens at a left-click. I'll finish adding in the other args and see if it works then.
Lyqyd #5
Posted 28 November 2014 - 02:40 AM
Is shutdown also nil? Passing two different nils won't do anything different in the function.