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

Error

Started by cory1234567, 10 January 2013 - 04:38 AM
cory1234567 #1
Posted 10 January 2013 - 05:38 AM
#UPDATED

Spoiler

local tArgs = {...}
local count = 0
function fuelCheck()
  if turtle.getFuelLevel() < 50 then
--    print(tostring(turtle.getFuelLevel()))
    turtle.select(16)
    turtle.refuel(1)
    turtle.select(1)
  end
end
function placeTorch()
  count = count + 1
--  print(tostring(count))
  if count == 10 then
    turtle.select(15)
    turtle.turnRight()
    turtle.place()
    turtle.turnLeft()
    turtle.select(1)
    count = 0
  end
end
for i = 1, tArgs[1] do
  fuelCheck()
  turtle.dig()
  turtle.forward()
  turtle.turnLeft()
  turtle.dig()
  turtle.digUp()
  turtle.up()
  turtle.dig()
  turtle.digUp()
  turtle.up()
  turtle.dig()
  turtle.turnRight()
  turtle.turnRight()
  turtle.dig()
  turtle.down()
  turtle.dig()
  turtle.down()
  turtle.dig()
  turtle.turnLeft()
  placeTorch()
end
turtle.select(14)
turtle.turnLeft()
turtle.place()
turtle.attack()
for i = 1,13 do
  turtle.select(i)
  turtle.drop()
end
turtle.select(14)
turtle.dig()
turtle.select(1)
turtle.turnRight()
turtle.back()
turtle.back()
OmegaVest #2
Posted 10 January 2013 - 06:05 AM
You never instantiate count. Add count = 1 to the top of the program.
cory1234567 #3
Posted 10 January 2013 - 06:12 AM
ok when i do that it just continues to count 2 it doesnt go to 3
2
2
2
2
OmegaVest #4
Posted 10 January 2013 - 06:19 AM
Can you update the code in your OP? I'm gonna think on this over lunch, but if it is a simple fix, it won't take me that long.
remiX #5
Posted 10 January 2013 - 07:15 AM
ok when i do that it just continues to count 2 it doesnt go to 3
2
2
2
2

You probably made count = 1 and put it in the beginning of the placeTorch() function. Put it right at the top of the code so it doesn't get reassigned to 1 all the time.
ChunLing #6
Posted 10 January 2013 - 09:34 AM
Yeah, put it right under your other program scoped declaration, local tArgs = {…} .
cory1234567 #7
Posted 16 January 2013 - 04:04 PM
could someone show me how to use the detect i tryed using if detect() then but it wouldnt work my turtle keeps getting messed up because of gravel and its really annoying
theoriginalbit #8
Posted 16 January 2013 - 04:12 PM
how to account for gravel in front of the turtle ( can work for any side with changing the directions )

while not turtle.forward() do
  turtle.dig()
  sleep(0.4) -- how long it takes gravel/sand to fall
end
and if your in CC1.4 you might want

while not turtle.forward() do
  if turtle.getFuelLevel() == 0 then
    print( "Out of fuel")
  elseif not turtle.dig() then
	turtle.attack() -- since mobs can stop a turtle from moving too
  end
  sleep(0.4) -- how long it takes gravel/sand to fall
end