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

Trying to check two conditions with two sets of values at the same time. Error is at line 10.

Started by CrowCrafter, 14 December 2012 - 09:29 AM
CrowCrafter #1
Posted 14 December 2012 - 10:29 AM
I've been iterating a program that makes a mining turtle strip mine for coding practice. It's been modular, so I'm pretty sure the error is coming from the new code which goes from lines 10 to 24. The error is ") expected at line 10", so it's a syntax error for sure. Is there any way to replace this line of code with a loop that can check three or more conditions and lead to the same block of code?

term.clear()
term.setCursorPos(1,1)
print("Enter the depth of the desired tunnel.")
input = tonumber(io.read())
neededTorches = input/5
neededFuel = input * 2
torchIt = 0
caveInCheck = false
inputorg = input
if (neededTorches > turtle.getItemCount(15) OR (turtle.getFuelLevel() * 2) < neededFuel)) == false then
   print("Insufficient supplies detected.")
   print("Please load:")
   if neededTorches > (turtle.getItemCount(15) then
	  print("["..neededTorches"] torches into slot 15.")
   end
   if turtle.getFuelLevel < neededFuel then
	  print("["..neededFuel"] heat units worth of combustable fuel into slot 1.")
   end
   if turtle.getItemCount(16) = 0 then
	  print("[1] or more chests of any type to slot 16.")
   end
   print("Once loaded, press ENTER to continue.")
   io.read()
end

while input > 0 do
   turtle.dig()
   turtle.suck()
   if turtle.detect() == true then
	  print("Cave in detected on depth level: "..input..". Compensating...")
	  caveInCheck = true
	  sleep(2)
   else
	  caveInCheck = false
   end
   turtle.forward()
   if caveInCheck == false then
	  turtle.digUp()
	  turtle.suckUp()
	  input = input - 1
	  torchIt = torchIt + 1
	  if torchIt == 6 then
		 turtle.back()
		 turtle.select(15)
		 turtle.placeUp()
		 turtle.forward()
		 torchIt = 0
	  end
   end
end
print("Tunneling Complete. Returning to origin point.")
turtle.turnLeft()
turtle.turnLeft()
while inputorg ~= 0 do
   turtle.forward()
   inputorg = inputorg - 1
end
turtle.turnRight()
turtle.select(16)
turtle.place()
for x = 1, 15, 1 do
   turtle.select(x)
   turtle.drop()
end
turtle.turnRight()
print("Standing by for next command.")
Doyle3694 #2
Posted 14 December 2012 - 10:34 AM
if not neededTorches > turtle.getItemCount(15) or not (turtle.getFuelLevel() * 2 < neededFuel) then

not rather than == false. or with non capital letters. Also, parentheses can mess up some stuff if used unproperly, I removed the outher ones ;)/>

Havn't tested, but should work
CrowCrafter #3
Posted 14 December 2012 - 10:49 AM
Hmm. Revised the code, but now it's throwing another error on the very same line: "then extpected on line 10".
Doyle3694 #4
Posted 14 December 2012 - 10:54 AM
Didn't notice, you had 1 to many close parentheses. Fixed now ;)/>
CrowCrafter #5
Posted 14 December 2012 - 10:59 AM
Hey! The error's location moved. Which is a good thing.

Thanks for the help. Time for more solo bug-squashing!