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

[Solved] Error + Where Are My Programs?

Started by colecf, 26 February 2012 - 12:37 AM
colecf #1
Posted 26 February 2012 - 01:37 AM
I'm making a tree harvesting program, but when trying to run it I get an error I didn't see on the error fixing post. It's:

harvest:15: attempt to compare __l t on bill and number

Line 15:

for i=0, i<width do -- assuming it counts empty lines

I don't really know what's wrong here. I'd post the entire source, but I don't know where to find my program as a file. I'm looking in mods/computercraft/lua/rom/programs, and it isn't there.
Advert #2
Posted 26 February 2012 - 01:46 AM
Your file is in saves/yourmap/computer/yourcomputerid/….

The error you're getting means that you're trying to do a mathematical comparison (less than/greater than) on nil and a number:
You're comparing i and width before i has been assigned.

I think you're mixing up a for and while loop; I think what you're trying to do would be this:

for i = 0, width-1 do -- Assuming that you want i to end at 1 less than width
 ...
end
colecf #3
Posted 26 February 2012 - 06:20 AM

for i = 0, width-1 do

Oh, duh! I'm used to C / Java, where the second parameter of the for loop compares i to something.

Thanks for your help.