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

Problems With A (2) Button

Started by CaosTECH, 07 November 2015 - 06:39 PM
CaosTECH #1
Posted 07 November 2015 - 07:39 PM
My brain is absolutely blown to pieces. It is not making sense and the code is right, it could be a problem with CC or something though

In my game, in the pause menu, I made buttons. But whenever I run the program, it says theres in error in line 117. It says it expected "then"
Here my code: I will try my best to explain the problem
while pauseMenu do
term.clear()
term.setCursorPos(2,2)
print("PAUSED")
term.setCursorPos(4,4)
term.setBackgroundColor(colors.blue)
print("		   ")
term.setCursorPos(4,5)
print("  UNPAUSE  ")
term.setCursorPos(4,6)
print("		   ")
term.setCursorPos(4,9)
term.setBackgroundColor(colors.red)
print("		   ")
term.setCursorPos(4,10)
print("   EXIT?   ")
term.setCursorPos(4,11)
print("		   ")
local event, button, x, y = os.pullEvent("mouse_click")
slc = 0
if (slc == 0) then

  if (event == "mouse_click")
  
	if (x >= 4 and x <= 15 and y >= 4 and y <= 6 and button == 1) then
	  pauseMenu = false
	  game = true
	elseif (x >= 4 and x <= 15 and y >= 9 and y <= 11 and button == 1) then
	  term.clear()
	  term.setCursorPos(1,1)
	  term.setBackgroundColor(colors.black)
	  term.setTextColor(colors.yellow)
	  term.clear()
	  print("Thanks for playing!")
	  break
	end
  end
end
end
This is Line 117:
	if (x >= 4 and x <= 15 and y >= 4 and y <= 6 and button == 1) then
It just doesn't make sense at all.
Lyqyd #2
Posted 07 November 2015 - 07:45 PM
It's expecting a then from the previous line, but still hasn't gotten it by the time it hits something else, so that's the line it throws the error on. This is covered in my favorite sticky post.