Jump to content




Neew help for Mining Turtle


3 replies to this topic

#1 Zephir

  • Members
  • 5 posts

Posted 23 June 2015 - 07:49 PM

Hey,
i have create my own Mining Script. It will Mine a 3x10x100 Tunnel.
Now i have 3 Problems.

1. If the Turtle dig a block an over that was gravel, the Turtle change the Route. How can i fix it?

2. If the Turtle are full, it would drop all items that have no space in the Turtle. Is there a code that the Turtle unload all Items in to a Chest?

3. Is there a Code that the Turtle refuel himself with mined coal?

Thanks for your Help.
Here is my Script:

for Start=1,50 do
turtle.dig()
turtle.forward()
turtle.turnRight()
for Mining=1,9 do
turtle.dig()
turtle.forward()
end
turtle.digUp()
turtle.up()
turtle.turnLeft()
turtle.turnLeft()
for Mining=1,9 do
turtle.dig()
turtle.forward()
end
turtle.digUp()
turtle.up()
turtle.turnRight()
turtle.turnRight()
for Mining=1,9 do
turtle.dig()
turtle.forward()
end
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
for Mining=1,9 do
turtle.dig()
turtle.forward()
end
turtle.digDown()
turtle.down()
turtle.turnRight()
turtle.turnRight()
for Mining=1,9 do
turtle.dig()
turtle.forward()
end
turtle.digDown()
turtle.down()
turtle.turnLeft()
turtle.turnLeft()
for Mining=1,9 do
turtle.dig()
turtle.forward()
end
turtle.turnRight()
end

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 23 June 2015 - 07:58 PM

1. If the Turtle dig a block an over that was gravel, the Turtle change the Route. How can i fix it?
-Sure, instead of using turtle.forward, use this:
local function forward()
  while not turtle.forward() do
    turtle.dig()
  end
  return true
end

2. If the Turtle are full, it would drop all items that have no space in the Turtle. Is there a code that the Turtle unload all Items in to a Chest?
-You can, turtle.drop() will drop an item in front of the turtle. If there is a chest in front of the turtle, it will drop the items into the chest.

3. Is there a Code that the Turtle refuel himself with mined coal?
-turtle.refuel refuels from the currently selected slot. Just do something like this:
local function getFuel()
  for i = 1, 16 do --#iterate through the slots (1-16)
    if turtle.refuel() then --#if there was fuel, we successfully used it
      break --#we don't have to keep looking
    end
  end
end


#3 Zephir

  • Members
  • 5 posts

Posted 23 June 2015 - 08:09 PM

Ok thank you very much... is there a code like this: if the Turtle are full, go to this Point?

Edited by Zephir, 23 June 2015 - 08:09 PM.


#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 24 June 2015 - 03:27 AM

You could easily check if the turtle is full.

local function isInventoryFilled()
  for i = 1, 16 do --#iterate through the slots
    if turtle.getItemCount( i ) == 0 then --#if one is free
      return false --#inventory is not full
    end
  end
  return true --#if none of the slots are empty, inventory is "full"
end

Note: the turtle could pick up 16 different items, and this would consider the inventory "full", even if there is only 1 of each item in the turtle.

Going to a location is harder, the turtle would have to know where he is and what direction he is facing. Not to mention avoiding or destroying obstructing blocks. There's a fair amount of 'goto' programs/utilities on the forums, you could try one of those.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users