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

program will not continue

Started by Flawlessgecko, 12 August 2013 - 03:02 PM
Flawlessgecko #1
Posted 12 August 2013 - 05:02 PM
Title:program will not continue


hey guys i have a simple program to make floor's but for some reason when i got to use the code it breaks after the first turnLeft() function i would appreciate any help:)

http://pastebin.com/GdBr62UN
campicus #2
Posted 12 August 2013 - 09:14 PM
Ok, let me point out a few improvements that might be made :)/>


turtle.refuel(64)
is the same as

turtle.refuel()

Your refuel function could use a repeat loop:


function checkFuel()
  if turtle.getFuelLevel < 5 then
    repeat
      print("I need Fuel please")
      print("fuel slot 16")
      turtle.select(16)
      turtle.refuel()
      turtle.getFuelLevel()
      if turtle.getFuelLevel() >5 then
        print(turtle.getFuelLevel())
        print("thanks I was thirsty")
      end
    until turtle.getFuelLevel > 5
  end
end
I'm not sure if you wanted the turtle moving forward in that function so I removed it.


function turtleFoward()
  if turtle.forward() == true then
  turtle.placeDown()
  else
	turtle.dig()
	turtle.forward()
	turtle.place()
  end
end
You don't really need the if function, just have him dig whether there is something there or not :)/>

I am not sure what your turtleLeft() function is meant to do… how about


function turnLeft()
  turtle.turnLeft()
  turtle.forward()
  turtle.turnLeft()
end

function row()
  for x = 1, blocks do
	turtleForward()
  end
  turnLeft()
  for x = 1, blocks do
	turtleForward()
  end
  turnRight() --You need to do a similar function to turnLeft(), but right...
end

while true do
  row()
end

hopefully this helps
Flawlessgecko #3
Posted 12 August 2013 - 10:41 PM
thanks so much this helped i was stumped for only one day of coding i guess its not too bad
Flawlessgecko #4
Posted 12 August 2013 - 10:44 PM
on the function checkfuel() with the until will loop it until it reach's more then 5 fuel
campicus #5
Posted 13 August 2013 - 12:26 AM
Yes, it will continue the checkFuel function until it has greater then 5 fuel