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

Functions wanting an additional "("

Started by Kyiki, 12 July 2015 - 09:26 AM
Kyiki #1
Posted 12 July 2015 - 11:26 AM
I've only recently started using computercraft, so I was expecting to run into errors, but I've been unable to find a solution(or similar problem). I was trying to make a simple testing program to clear a 21x21x2 area out, or at least to do 21x2 then turn so it is positioned to be restarted automatically. However, when i tried to put a turnaround function into the program, i recieved a - bios:366: [string "test"]:4: '(' expected - message.

—-
  1. turtle.forward()
  2. local function left
  3. turtle.turnLeft()
  4. end
  5. local function aboutFace
  6. left
  7. turtle.forward()
  8. left
  9. end
  10. aboutFace()

—-
Any help is greatly appreciated.
The_Cat #2
Posted 12 July 2015 - 06:34 PM
Basically in most languages when create a function you need to add brackets:

function left()
  --#Your Code
end
local function aboutFace()
  --#Your Code
end
And when you call functions you need to do:
left()
aboutFace()
Edited on 12 July 2015 - 04:38 PM
Kyiki #3
Posted 12 July 2015 - 11:11 PM
ah, thank you very much!