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

Problem with the turtle movement functions (i.e. turtle.forward(), turtle.up() etc.)

Started by Legato, 01 December 2013 - 10:26 AM
Legato #1
Posted 01 December 2013 - 11:26 AM
So, first a little bit of background. Having looked around at the different strip mining programs out there, I found that none was quite what I was looking for and thus decided to attempt to make my own. Alas, I quickly encountered a problem that I cannot seem to solve. The code, as it is, looks like this http://pastebin.com/VhaefF6U

local args={...}

--Gets the values provided as args at start of program and asignes them to lenght, rows and height
local lenght = tonumber(args[1])
local rows = tonumber(args[2])
local height = tonumber(args[3])

--Sets maximun values for lenght, number of rows and height of tunnel
local lenghtl=128
local rowsl=16
local heightl=15

--Checks that values have been provided
if lenght==nil or rows==nil or height==nil then
  print("Lenght, number and height must be provided")
  print("Please use as:\nstripmine [lenght] [rows] [height]")

--Checks so that the provided values don't exceed the maximun limit
elseif lenght>lenghtl and rows>rowsl and height>7 then
  print("Value exceeding limit was detected. The limits are -\n")
  print("Lenght: "..lenghtl.."\nRows: "..rowsl.."\nHeight: "..heightl)
else
  --Loop to put turtle at correct initial vertical position
  for i=0, height do
	if turtle.detectUp() then
	  turtle.digUp()
	end
	turtle.up()
  end

end

The problem is, no matter what I do, I cannot make the turtle use the turtle.up() function. Actually, none of the movement functions produce any result whatsoever, even if the turtle is put in a huge area with empty space in every direction. I have tested this repeatedly with the small function

for i=1, 16 do
if turtle.forward() then
turtle.forward()
print("forward +1")
else
print("Movement failed")
end
sleep(0.5)
end
for all movement functions, with no success for any of them.
Does anyone have any idea of why this isn't working?

Regards,
[indent=1]Legato[/indent]
Lyqyd #2
Posted 01 December 2013 - 02:48 PM
Have you fueled the turtle?
Legato #3
Posted 01 December 2013 - 02:57 PM
Yes.
Lyqyd #4
Posted 01 December 2013 - 03:30 PM
So, you placed a fuel object in it, used either turtle.refuel() or ran the refuel program, the fuel item was consumed, and it now has fuel points in it? Open up the lua console and put in turtle.getFuelLevel() and tell us what it prints.
Legato #5
Posted 01 December 2013 - 03:53 PM
Ah, that did it. Whops ^^'
Anyway, I think I'll be able to fix it with this, thanks!