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

Mining Turtle Help

Started by applesauce10189, 21 February 2014 - 11:49 AM
applesauce10189 #1
Posted 21 February 2014 - 12:49 PM
I'm new/bad at coding so I'm making programs to practice/get better at coding, I have a mining turtle program that mines how far down you choose and can optionally place torches before it digs an endless 3x3.

http://www.computercraft.info/forums2/index.php?/topic/16321-mining-turtle-program/page__fromsearch__1

The thing is, when you're digging an endless 3x3, at some point it's going to leave the chunk loaded area and that'll be a problem. I'm making this program with a mod pack, specifically FTB Unleashed 1.1.7 if that helps with anything. Also thinking of switching to Direwolf20 1.6.4 pack. Back to the point, how can I use chunk loaders with my program? Another question I have is since I'm making programs to help me get better at coding, what are some program ideas that would be good practice for a beginner?


term.clear()
term.setCursorPos(1,1)
print("Place torches?")
print("1 = Yes 2 = No")
local x = read()
local test = 0
term.clear()
term.setCursorPos(1,1)
print("How far down should I dig?")
swag = read()
swag = tonumber(swag)
  if tonumber(x) == 1 then
    test = test + 1
  end

function appleTunnel()
  turtle.digDown()
  while true do
  turtle.up()
  turtle.dig()
  gravityCheck()
  turtle.forward()
  turtle.turnRight()
  turtle.dig()
  gravityCheck()
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.dig()
  gravityCheck()
  turtle.turnRight()
  turtle.digDown()
  gravityCheck()
  turtle.down()
  turtle.turnRight()
  turtle.dig()
  gravityCheck()
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.dig()
  gravityCheck()
  turtle.turnRight()
  turtle.digDown()
  turtle.down()
  turtle.turnRight()
  turtle.dig()
  gravityCheck()
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.dig()
  gravityCheck()
  turtle.turnRight()
  turtle.up()
end
end

function placeTorches()
  if test == 1 then
    turtle.select(3)
    turtle.place()
    turtle.select(1)
  end
end

function emptyInventory()
  for i = 4, 16 do
    turtle.select(i)
    turtle.dropDown(64)
  end
end

function gravityCheck()
  while turtle.dig() do
    if turtle.dig() == false then
      break
    end
  end
end

function appleMine()
    for i = 1,swag do
      turtle.select(1)
      turtle.digDown()
      turtle.down()
      turtle.digDown()
      turtle.down()
      turtle.turnRight()
      turtle.dig()
      gravityCheck()
      turtle.turnLeft()
      turtle.turnLeft()
      turtle.dig()
      gravityCheck()
      turtle.turnRight()
      turtle.dig()
      gravityCheck()
      turtle.forward()
      turtle.turnRight()
      turtle.dig()
      gravityCheck()
      turtle.turnLeft()
      turtle.turnLeft()
      turtle.dig()
      gravityCheck()
      turtle.turnRight()
      turtle.dig()
      gravityCheck()
      turtle.forward()
      turtle.turnRight()
      turtle.dig()
      gravityCheck()
      turtle.turnLeft()
      turtle.turnLeft()
      turtle.dig()
      gravityCheck()
      turtle.turnRight()
      turtle.dig()
      gravityCheck()
      turtle.forward()
      turtle.turnRight()
      turtle.dig()
      gravityCheck()
      turtle.turnLeft()
      turtle.turnLeft()
      turtle.dig()
      gravityCheck()
      turtle.turnRight()
      turtle.back()
      placeTorches()
      turtle.back()
      turtle.up()
      turtle.placeDown()
      emptyInventory()
      appleFuel()
    end
end
function appleFuel()
  if turtle.getFuelLevel() <= 50 then
    turtle.select(2)
    turtle.placeUp()
    turtle.suckUp()
    turtle.refuel(64)
    turtle.digUp()
  end
end
turtle.select(1)
appleMine()
appleTunnel()
Bomb Bloke #2
Posted 21 February 2014 - 07:59 PM
Apparently, a turtle will indeed stop if you move so far away from it that its chunk unloads - but if it moves from a loaded chunk into an unloaded one, then that chunk will become loaded. So if a player's stationary or simply nowhere near the turtle, then in theory it should be able to go where ever it likes so long as it starts off in a loaded zone.

Not 100% reliable if players are operating in the area, but interesting none the less.

Anyway, having a turtle carry a single chunk loader block around with it is risky for similar reasons. To be reliable, it'd need to carry at least two chunk loaders, each capable of loading multiple chunks - it'd place one, move into the next chunk and place the other, then go BACK and recollect the first. Then sort of leap-frog its way across the world like that.

Another option is to have two turtles - give one the chunk loader peripheral (from MiscPeripherals), then just have it follow the miner around.
CometWolf #3
Posted 21 February 2014 - 08:08 PM
Another option is to have two turtles - give one the chunk loader peripheral (from MiscPeripherals), then just have it follow the miner around.
Might aswell put the chunk loader peripheral on the miner in that case.
Since he's on unleashed, he should indeed have acess to it.
applesauce10189 #4
Posted 22 February 2014 - 10:00 PM
Another option is to have two turtles - give one the chunk loader peripheral (from MiscPeripherals), then just have it follow the miner around.
Might aswell put the chunk loader peripheral on the miner in that case.
Since he's on unleashed, he should indeed have acess to it.
Chunk loading mining turtle without a chunk loader to place. Please explain your sorcery to me.

EDIT: Through the power of google (and/or a MiscPeripherals link above) I have managed to find out more about a magical self-chunkloading turtle. Amazing.
Edited on 22 February 2014 - 09:07 PM
Bomb Bloke #5
Posted 22 February 2014 - 10:13 PM
Might aswell put the chunk loader peripheral on the miner in that case.
Since he's on unleashed, he should indeed have acess to it.
I get so caught up on reserving a peripheral slot on all of my own turtles for modems that this somehow didn't occur to me.
applesauce10189 #6
Posted 23 February 2014 - 07:08 PM
Apparently, a turtle will indeed stop if you move so far away from it that its chunk unloads - but if it moves from a loaded chunk into an unloaded one, then that chunk will become loaded. So if a player's stationary or simply nowhere near the turtle, then in theory it should be able to go where ever it likes so long as it starts off in a loaded zone.

Not 100% reliable if players are operating in the area, but interesting none the less.

Anyway, having a turtle carry a single chunk loader block around with it is risky for similar reasons. To be reliable, it'd need to carry at least two chunk loaders, each capable of loading multiple chunks - it'd place one, move into the next chunk and place the other, then go BACK and recollect the first. Then sort of leap-frog its way across the world like that.

Another option is to have two turtles - give one the chunk loader peripheral (from MiscPeripherals), then just have it follow the miner around.
Little problem with what you said, how far down it digs is optional so you never know if it will dig down an even or odd amount of blocks before it digs the 3x3.
Bomb Bloke #7
Posted 23 February 2014 - 07:24 PM
Sorry, I'm not sure what that has to do with what I was talking about.

If it helps, a simplistic way to tell if a given number is odd or even is to perform modulus two on it (which divides the number by two and returns the remainder). Depending on whether the result is zero or one, you know whether the original number was even or odd.

Eg:

if i % 2 == 0 then
  -- 'i' is even.
else
  -- 'i' is odd.
end

Edit: Note that what I'd said in that post you quoted is mostly redundant if you're able to just slap a chunk loader peripheral on your miner, as Comet pointed out.
Edited on 23 February 2014 - 06:25 PM
applesauce10189 #8
Posted 24 February 2014 - 10:42 AM
Well on to the second question in this thread. Towards the top I also said "Another question I have is since I'm making programs to get better at coding, what's some good practice for a beginner?"
When I say good practice for a beginner, I mean like something that would be possible for someone new like me yet still a little bit of a challenge or something along those lines.
Thib0704 #9
Posted 24 February 2014 - 10:51 AM
Well on to the second question in this thread. Towards the top I also said "Another question I have is since I'm making programs to get better at coding, what's some good practice for a beginner?"
When I say good practice for a beginner, I mean like something that would be possible for someone new like me yet still a little bit of a challenge or something along those lines.
Coding, Coding, Coding…. :P/>
applesauce10189 #10
Posted 24 February 2014 - 11:17 AM
Well on to the second question in this thread. Towards the top I also said "Another question I have is since I'm making programs to get better at coding, what's some good practice for a beginner?"
When I say good practice for a beginner, I mean like something that would be possible for someone new like me yet still a little bit of a challenge or something along those lines.
Coding, Coding, Coding…. :P/>
That's kinda irrelevant, as I said above, I'm wondering if anybody has any ideas as to what kinda program I can make for practice.
Alice #11
Posted 24 February 2014 - 11:21 AM
Work on a practical program, such as a small game, or a todo list program.
Bomb Bloke #12
Posted 24 February 2014 - 05:52 PM
Has anyone made an API for rendering/moving/detecting clicks on playing cards yet? That'd be kinda cool. You could then make eg solitaire out of it.