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

'(' expected

Started by Natabam, 14 August 2016 - 04:33 PM
Natabam #1
Posted 14 August 2016 - 06:33 PM
Hey!

I am currently writing a program for my mining turtle. But the problem is, that when I start the program it gives me the error message "'(' expected" in line 4.
Could you please help me with this problem?

Here's my program:

local searchedBlock = "minecraft:diamond_ore"
function forceForward
  while turtle.forward() == false do
    turtle.dig()
  end
end
function forceUp
  while turtle.up() == false do
    turtle.digUp()
  end
end
function forceDown
  while turtle.down() == false do
    turtle.digDown()
  end
end
function forceBack
  while turtle.back == false do
    turtle.turnRight()
turtle.turnRight()
searchForBlock()
turtle.turnRight()
turtle.turnRight()
  end
end
function inspectAll
  searchForBlockUp()
  searchForBlockDown()
  for i=1, 4 do
    searchForBlock()
    turtle.turnRight()
  end
end
function searchForBlock
  success, data = turtle.inspect()
  if success and data.name == searchedBlock then
    forceForward()
    inspectAll()
    forceBack()
  end
end
function searchForBlockUp
  success, data = turtle.inspectUp()
  if success and data.name == searchedBlock then
    forceUp()
    inspectAll()
    forceDown()
  end
end
function searchForBlockDown
  success, data = turtle.inspectDown()
  if success and data.name == searchedBlock then
    forceDown()
    inspectAll()
    forceUp()
  end
end
for i=1, 100 do
  turtle.forward()
  inspectAll()
end

regards, Natabam
Lyqyd #2
Posted 14 August 2016 - 08:53 PM
When declaring functions, you need the parentheses, even if your function takes no arguments:


local function myFunctionName()
Natabam #3
Posted 14 August 2016 - 09:00 PM
Oh god I didn't know this :o/>

Thank you very much!

regards, Natabam