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

Error autofloor:7: attempt to call nil

Started by Envy_x, 08 April 2013 - 09:35 PM
Envy_x #1
Posted 08 April 2013 - 11:35 PM
[Solved]
Hi, I have just started to muck around with these turtles and have encountred this problem.
Please Help
Code: http://pastebin.com/vNv96JE0
Please Pm me if you find a solution.
[Solved]
Lyqyd #2
Posted 09 April 2013 - 06:36 AM
Split into new topic.

Line 7 should use `turtle.detect()` not `turtle.detectForward()`.
PixelToast #3
Posted 09 April 2013 - 06:37 AM
turtle.detectForward() isnt a function
you want turtle.detect()
SadKingBilly #4
Posted 09 April 2013 - 06:51 AM
Also, too many "end"s in your functions. And get rid of the "do"s in your function definitions.
TheOddByte #5
Posted 09 April 2013 - 12:14 PM
Uhmm… Just do this


--[AutoFloorv1]--


print "Starting"

function detectwall() --Removed 'do' here
  if not turtle.detect()  then --Used 'not' instead of '== false' since they are pretty much the same
  turtle.forward()
   else 
      turtle.turnLeft()
      turtle.forward()
      turtle.turnLeft()
    end    
  end
 --[[
Removed an 'end' here since you just need 2
One for the function and one for the 'if'
]]--

function placeblock()
  if not turtle.detectDown()  then
  turtle.placeDown()
    else
      turtle.forward()
    end
  end


while true do
  placeblock()
    detectwall()
    end

Think that's correct..
Envy_x #6
Posted 09 April 2013 - 05:31 PM
Thank you all for input will remember these things for next time. :D/>