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

Attempt to call nil -- after running a program

Started by MiningEng, 09 July 2017 - 08:41 AM
MiningEng #1
Posted 09 July 2017 - 10:41 AM
Hello dear Pro's,

I have a problem with error "Attempt to call nil". It comes after running a program.
The program runs without problem, but then I can't use the Lua-console at the turtle.

For example: I let the program run and then I want the turtle to go back with turtle.back(). Then there is the error.

Why is this always coming after running a program?


Greetings
Bomb Bloke #2
Posted 09 July 2017 - 11:43 AM
That'd likely depend on the content of your program. Odds are it's replacing the regular "turtle" table with one that doesn't contain the "back", "forward", "turnLeft", etc keys.
MiningEng #3
Posted 09 July 2017 - 03:43 PM
This is my program:


weitermachen = true
tiefe = 1
while weitermachen do
-- Graben
turtle.digDown()
turtle.down()
-- Graben abbrechen
success, table = turtle.inspectDown()
if table.name == "minecraft:bedrock" or table.name == "minecraft:lava" then
  weitermachen = false
end

tiefe = tiefe + 1
end
for j = 1, tiefe-1 do
turtle.up()
end

What can I do? What is wrong?
KingofGamesYami #4
Posted 09 July 2017 - 04:34 PM
You are overwriting the "table" api with the results of turtle.inspectDown(). Use another name, such as tbl.
MiningEng #5
Posted 09 July 2017 - 05:13 PM
Thanks :)/>