ComputerCraft Program Help

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • FTB will be shutting down this forum by the end of July. To participate in our community discussions, please join our Discord! https://ftb.team/discord

SNEAKYxBEAVER

New Member
Jul 29, 2019
3
0
0
Every time I try to run this program for chopping down redwoods I get this message, "Fell :53: attempt to index ? (a nil value)" If anyone could help me out with this problem that would be great. Here is the program link: http://pastebin.com/A89YVycp
And the program:
local function checkFuel()
if turtle.getFuelLevel() < 1 then
turtle.select(1)
turtle.refuel(1)
end
end

local function column()
while turtle.digUp() do
turtle.dig()
checkFuel()
turtle.up()
end
turtle.dig()

checkFuel()
while turtle.down() do
checkFuel()
end
end

local function digmove()
checkFuel()
turtle.dig()
turtle.forward()
end

local function plant()
turtle.select(2)
turtle.forward(1)
turtle.place()
turtle.turnRight()
turtle.forward(1)
turtle.turnLeft()
turtle.place()
turtle.turnRight()
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.turnRight()
turtle.place()
turtle.turnLeft()
turtle.forward(1)
turtle.turnRight()
turtle.place()
end

local function dropwood()
for i=3, 16 do
turtle.select( i)
turtle.dropDown()
end
turtle.select(3)
end

while true do --Always loop

dropwood()

plant()

turtle.up()
local Wait, Correct = "0", "1"
while Wait~=Correct do
if turtle.detect()==true then
Wait = "1"
print("success")
end
sleep(5)
end
turtle.down()

digmove()
column()
turtle.turnRight()
digmove()
turtle.turnLeft()
column()
turtle.turnLeft()
digmove()
digmove()
turtle.turnRight()
column()

turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.turnRight()

end
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
Every time I try to run this program for chopping down redwoods I get this message, "Fell :53: attempt to index ? (a nil value)" If anyone could help me out with this problem that would be great. Here is the program link: http://pastebin.com/A89YVycp
And the program:

Code:
local function checkFuel()
if turtle.getFuelLevel() < 1 then
turtle.select(1)
turtle.refuel(1)
end
end
 
local function column()
while turtle.digUp() do
turtle.dig()
checkFuel()
turtle.up()
end
turtle.dig()
 
checkFuel()
while turtle.down() do
checkFuel()
end
end
 
local function digmove()
checkFuel()
turtle.dig()
turtle.forward()
end
 
local function plant()
turtle.select(2)
turtle.forward(1)
turtle.place()
turtle.turnRight()
turtle.forward(1)
turtle.turnLeft()
turtle.place()
turtle.turnRight()
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.turnRight()
turtle.place()
turtle.turnLeft()
turtle.forward(1)
turtle.turnRight()
turtle.place()
end
 
local function dropwood()
for i=3, 16 do
turtle.select( i)
turtle.dropDown()
end
turtle.select(3)
end
 
while true do --Always loop
 
dropwood()
 
plant()
 
turtle.up()
local Wait, Correct = "0", "1"
while Wait~=Correct do
if turtle.detect()==true then
Wait = "1"
print("success")
end
sleep(5)
end
turtle.down()
 
digmove()
column()
turtle.turnRight()
digmove()
turtle.turnLeft()
column()
turtle.turnLeft()
digmove()
digmove()
turtle.turnRight()
column()
 
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.turnRight()
 
end

First off, use the CODE tags ([ code ], [ /code ]) for your code, and possibly the SPOILER tags as well.

Secondly, the error code is telling you what line number the error is one. Review that line, and if you don't get it by then, tell me.


for int i=3,16 do

Is that it?


That is an attempted for loop. It appears to have been corrected in the original post, though. Incorrectly so.
 

BlackFire

New Member
Jul 29, 2019
344
0
0
Exactly, if i isn't initialized as an integer, it would return a nil error right? I could be wrong
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
Yup, your right. Too much java in my blood

Yeah, LUA will make most any programmer vomit in delight. Why they decided to go with it, well, I'm not sure, but at least they didn't decide to go with something truly horrid such as coconut-based programming.
 

zemerick

New Member
Jul 29, 2019
667
0
1
Well, I used the pastebin code and couldn't get it to crash. Perhaps some more background on the problem?

According to the error, the problem is with:
turtle.select(3)

which works just fine.

Unless there's more above this in the same program, which could offset the line number.