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

[Lua][Error][Question] How to read error messages[SOLVED]

Started by Ikkalyzte, 30 June 2012 - 10:04 PM
Ikkalyzte #1
Posted 01 July 2012 - 12:04 AM
First of all, please excuse my messy/noobish code. This is about my second program :)/>/>
Anyway, when I run my tree-farming script, I get this error:

bios:206: [string "FarmTree"]:111: ')' expected

Here is the program:

====================================================================

shell.run('clear')
textutils.slowPrint("Initialization in progress…")
print("This Turtle is programmed for a fenced in, rectangular birch tree farm, with 2 spaces between each tree, and a one-block space around the whole farm.")
sleep(1)
print("I am supposed to be placed in the bottom-left corner of the farm. If this is not the case, please move me there and try again.")
sleep(1)
print("Please fill the upper-left slot with saplings, and place one log in the top-center slot.")
print("When finished, press enter to continue.")
io.read()

–Auto-init:

L=0 –length of farm
W=0 –width of farm

while not turtle.detect() do
turtle.forward()
turtle.turnLeft()
if turtle.compare()==true then
L=L+1
end
turtle.turnRight()
turtle.forward()
end
turtle.turnLeft()
turtle.turnLeft()

x=3*L

for e=1,x do
turtle.forward()
end
turtle.turnRight()

while not turtle.detect() do
turtle.forward()
turtle.turnRight()
if turtle.compare()==true then
W=W+1
end
turtle.turnLeft()
turtle.forward()
end
turtle.turnRight()
turtle.turnRight()

y=3*W

for f=1,y do
turtle.forward()
end
turtle.turnLeft()

print("Initialization complete! Beginning farming…")

–Actual Farming

while true do
while turtle.getItemCount(1)>16 do
for a=1,W do
for b=1,L do
turtle.forward()
turtle.turnLeft()
turtle.select(2)
if turtle.compare()==true then
turtle.dig()
turtle.forward()
while turtle.detectUp() do
turtle.digUp()
turtle.up()
end
while not turtle.detectDown() do
turtle.down()
end
turtle.back()
turtle.select(1)
turtle.place()
end
turtle.turnRight()
turtle.forward()
if not turtle.detect() then
turtle.forward()
end
end

turtle.turnLeft()
turtle.turnLeft()
for c=1,x do
turtle.forward()
end
turtle.turnRight()
turtle.forward()
turtle.forward()
if not turtle.detect() then
turtle.forward()
end
turtle.turnRight()
end
turtle.turnRight()
for d=1,y do
turtle.forward()
end
turtle.turnLeft()
end
print("Sapling supplies running low. Please refill and remove wood.")

two, three, four, five, six, seven, eight, nine = turtle.getItemCount(2), turtle.getItemCount(3), turtle.getItemCount(4), turtle.getItemCount(5), turtle.getItemCount(6), turtle.getItemCount(7), turtle.getItemCount(8), turtle.getItemCount(9)
T=two+three+four+five+six+seven+eight+nine
S=turtle.getItemSpace(1)

textutils.slowPrint("Wood collected: roughly "…T)
textutils.slowPrint("Trees cut down: "…S)
print("Please press enter when emptied & restocked.")
io.read()
end

==============================================================

I would assume that this means that I have forgotten to input a closing parenthesis at the 111th line. However, I can't find anything I missed, so I figured this would be the best place to come for help. My program is named FarmTree, as obvious, and it is located in the rom directory (I made it in a text editor then saved it there).

Secondly, can anyone point me to a reliable error-reading guide? I have looked around for a little while, and haven't been able to figure out whether I'm reading the error output correctly.

Thanks to anyone who helps, and let me know if more information is needed.

Edit: Posted file wrongly
MysticT #2
Posted 01 July 2012 - 12:30 AM
To concatenate strings you only need 2 .
So, this:

textutils.slowPrint("Wood collected: roughly "...T)
textutils.slowPrint("Trees cut down: "...S)
should be:

textutils.slowPrint("Wood collected: roughly "..T)
textutils.slowPrint("Trees cut down: "..S)
Ikkalyzte #3
Posted 01 July 2012 - 12:32 AM
Haha I just figured that out. Thanks for the help!
I still haven't found an official way to read errors though…
MysticT #4
Posted 01 July 2012 - 12:44 AM
Well, it's really easy, the error messages are like this:
<File>:<Line>:<Error Message>

When you run a program inside another program, it will be like:
<File1>:<Line>:<File2>:<Line>:<Error Message>

So, most of the time you'll see:
bios:<Line>:<File>:<Line>:<Error Message>
that's because the programs are run from the bios.
Ikkalyzte #5
Posted 01 July 2012 - 12:58 AM
Ok, cool! Thanks for the super-quick response. I just couldn't find that information put that clearly anywhere else, and so wasn't sure if I was doing it right.