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

Bios:339 :57 '<name>' expected

Started by Yeti, 25 April 2015 - 08:23 PM
Yeti #1
Posted 25 April 2015 - 10:23 PM
Hi i have a problem with my program. The error is already described in the topic title. Here is the link to the code :
http://pastebin.com/7HNVhmgB

I searched for more than an hour but the only thing I could find was the same error with no answer or different errors. Neither of them could help me so i hope you can do so.
The program itself should make something like a mountain flat. If there is any question regarding the program don't hesitate to ask me about it. In general the program is running but the print-function isn't working which would not be necessary but really great.

Thanks for your answers

Yeti
HPWebcamAble #2
Posted 26 April 2015 - 01:18 AM
Well, this is line 57:


print  . . b - a . . " fuel are remaining "

You don't need to do any math, just use 'turtle.getFuelLevel()'


print( turtle.getFuelLevel() .. " fuel remaining" ) 
You can do it without the parenthesizes for print, but its better to use them.
( turtle.getFuelLevel() has to have them )
Bomb Bloke #3
Posted 26 April 2015 - 01:23 AM
Note that this isn't eg BASIC - if you want to pass more than a single argument to a function, the brackets are required. Many, if not most, coders use the brackets under all circumstances, for the sake of consistency.
Lignum #4
Posted 26 April 2015 - 01:24 AM
You can do it without the parenthesizes for print, but its better to use them.

As soon as the string is not constant, you can't omit the parentheses. So you would have to use them in this case regardless.
Yeti #5
Posted 26 April 2015 - 07:15 PM
Well, this is line 57:


print  . . b - a . . " fuel are remaining "

You don't need to do any math, just use 'turtle.getFuelLevel()'


print( turtle.getFuelLevel() .. " fuel remaining" )
You can do it without the parenthesizes for print, but its better to use them.
( turtle.getFuelLevel() has to have them )

But with " turtle.getFuelLevel() " the program won't say me how much fuel i still need to refill to run the hole program. this is the task of the line 57.

You can do it without the parenthesizes for print, but its better to use them.

As soon as the string is not constant, you can't omit the parentheses. So you would have to use them in this case regardless.

I tried the program with parentheses/ brackets but there is still the same error or I placed them in the wrong place
MKlegoman357 #6
Posted 26 April 2015 - 07:45 PM
I tried the program with parentheses/ brackets but there is still the same error or I placed them in the wrong place

Where did you put them?