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

Mouse click doesn't work?

Started by 27thColt, 02 May 2013 - 08:24 PM
27thColt #1
Posted 02 May 2013 - 10:24 PM
I am trying to make an OS for non-advance computers.
Spoiler

--CraftOS+ 1.0.0 created by:27thColt

function menu()  
  term.clear()
  term.setCursorPos(1, 1)
  print("X---------------------------------X")
  term.setCursorPos(36, 1)
  print("[Shutdown]")
  term.setCursorPos(1, 2)
  print("CraftOS+ 1.0.0")
  term.setCursorPos(36, 2)
  print("[Restart]")
  term.setCursorPos(1, 4)
  print("X---------------------------------X")
 
end

menu()
while true do
  local event button, X, Y = os.pullEventRaw()
  if event == "mouse_click" then
    if X >= 36 and X <= 45 and Y == 1 and button == 1 then
	  term.setCursorPos(1, 4)
	  print("Shutting down....")
	  os.sleep(2)
	  os.shutdown()
	  elseif X >= 36 and X <= 44 and Y == 2 and button == 1 then
	    term.setCursorPos(1, 4)
	    print("Restarting....")
	    os.reboot()
	 end
   end
end
	  

As you can see,I want it so if you click restart,it will reboot.But clicking restart won't do anything.If I click shutdown,it doesn't do anything either.I looked at all of my code.I don't see anything wrong.Can anyone help me??
Kingdaro #2
Posted 02 May 2013 - 10:26 PM
Normal computers don't have click support.
27thColt #3
Posted 02 May 2013 - 10:29 PM
Normal computers don't have click support.

ok….well I actually tested it on my advanced computer,it still doesn't work.The Least I can do is correct my mistake
remiX #4
Posted 03 May 2013 - 12:57 AM
Missed a comma on this line:
local event button, X, Y = os.pullEventRaw()
needs a comma between event and button
27thColt #5
Posted 03 May 2013 - 10:50 PM
Missed a comma on this line:
local event button, X, Y = os.pullEventRaw()
needs a comma between event and button

oh.