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

chunk loader?

Started by jakemg, 07 April 2013 - 06:52 PM
jakemg #1
Posted 07 April 2013 - 08:52 PM
Edit: i figured out my chunk loader issue
New problem :P/> :

I am wondering how to put a torch feature in, i had an idea but i realised that it would put a torch down every block so I cant quite figure out how to get a torch feature in this program


local tArgs = {...}
local times = tArgs[1] and tonumber(tArgs[1]) or 1
turtle.select(1)
function move()
  while not turtle.forward() do  --this loop runs as long as turtle.move() return false
	    turtle.dig() --dig its way through
	    sleep(0.8) --i think this is falling time of gravel
  end
end

for i = 1, times do
	    turtle.dig()
	    move()
	    turtle.digUp()
	    turtle.turnRight()
	    turtle.dig()
	    move()
	    turtle.digUp()
	    turtle.digDown()
   turtle.dig()
	    turtle.turnRight()
	    turtle.turnRight()
	    move()
   move()
   turtle.dig()
	    turtle.digUp()
	    turtle.digDown()
   turtle.turnLeft()
	    turtle.turnLeft()
	    move()
	    turtle.turnLeft()
	    if turtle.getItemCount(16) > 0 then
			    turtle.select(1)
			    turtle.placeUp()
			    turtle.select(3)
			    for i = 3, 16 do
					    turtle.select(i)
					    turtle.dropUp()
			    end
			    turtle.select(1)
			    turtle.digUp()
	    end
end
function home()
	    for i = 1, times do -- notice the loop
			    move()
	    end
end
function torch()
turn

function turn()
	    turtle.turnLeft()
	    turtle.turnLeft()
end

turn()
home()
jakemg #2
Posted 07 April 2013 - 09:16 PM
Is there a code for like every 10 blocks do this function because I think thats what I need
theoriginalbit #3
Posted 07 April 2013 - 09:19 PM
Is there a code for like every 10 blocks do this function because I think thats what I need
you will have to keep a record of how far it has been moved, so basically each time you move increment the number, then you can do this

if theDistanceVar % 10 == 0 then
  -- do what you want, it has moved a multiple of 10 blocks
end

EDIT: based off your code, you could use the variable 'i' as your distance variable.
Edited on 07 April 2013 - 07:20 PM
jakemg #4
Posted 07 April 2013 - 09:31 PM
i didnt even think about that Thanks =D