Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --v1.2
- -- If my vein miner program doesn't exist, it will be automatically downloaded.
- if not fs.exists("VeinMiner.lua") then
- shell.run("pastebin","get","0C6LyNES","VeinMiner.lua")
- end
- require("VeinMiner")
- function refuel()
- -- Tries to refuel if fuel level is low.
- while turtle.getFuelLevel() == 0 do
- for a = 1, 16 do
- turtle.select(a)
- turtle.refuel(1)
- end
- end
- end
- move = {
- forward = function(x)
- -- Tries to travel forward. May be blocked by entities.
- -- Input x for distance to travel, or nothing to travel 1 only one block.
- if not x then x = 1 end
- for a = 1, x do
- repeat
- refuel()
- turtle.dig()
- until turtle.forward()
- end
- end,
- back = function(x)
- -- Tries to travel backward. May be blocked by entities or blocks.
- -- Input x for distance to travel, or nothing to travel 1 only one block.
- if not x then x = 1 end
- for a = 1, x do
- repeat
- refuel()
- until turtle.back()
- end
- end,
- up = function(x)
- -- Tries to travel upward. May be blocked by entities.
- -- Input x for distance to travel, or nothing to travel 1 only one block.
- if not x then x = 1 end
- for a = 1, x do
- repeat
- refuel()
- turtle.digUp()
- until turtle.up()
- end
- end,
- down = function(x)
- -- Tries to travel downward. May be blocked by entities.
- -- Input x for distance to travel, or nothing to travel 1 only one block.
- if not x then x = 1 end
- for a = 1, x do
- repeat
- refuel()
- turtle.digDown()
- until turtle.down()
- end
- end,
- left = function(x)
- -- Turns left.
- -- Input x for how many times to turn, or nothing to turn once.
- if not x then x = 1 end
- for a = 1, x do
- turtle.turnLeft()
- end
- end,
- right = function(x)
- -- Turns right.
- -- Input x for how many times to turn, or nothing to turn once.
- if not x then x = 1 end
- for a = 1, x do
- turtle.turnRight()
- end
- end
- }
- function hallway(y, x, veinMiner)
- -- Creates a 2 or 3 block tall hallway by digging one block above, below, and in front.
- -- Input x for distance to travel, or nothing to travel 1 only one block.
- -- Input y for hallway height. -1 = dig below. 1 = dig above. 0 = dig above and below.
- if not x then x = 1 end
- for a = 1, x do
- move.forward()
- if veinMiner then
- shell.run("VeinMiner.lua")
- end
- if y >= 0 then
- turtle.digUp()
- end
- if y <= 0 then
- turtle.digDown()
- end
- end
- end
- function place(dir, block, damage, sign)
- -- Searches for specified item in inventory and tries to place it in the world.
- -- Input dir for which direction to place the block.
- -- Input block for the item ID. Input damage for the item variant (i.e.: 0 = Stone, 1 = Granite, etc.).
- -- Input sign for the text to display on a sign. Leave blank for no text.
- local placeBlock = 0
- if not sign then sign = "" end
- repeat
- for a = 1, 16 do
- local item = turtle.getItemDetail(a)
- if item and item.name == block and item.damage == damage then
- placeBlock = a
- end
- end
- until placeBlock > 0
- turtle.select(placeBlock)
- if dir == "forward" then
- turtle.dig()
- turtle.place(sign)
- elseif dir == "up" then
- turtle.digUp()
- turtle.placeUp(sign)
- elseif dir == "down" then
- turtle.digDown()
- turtle.placeDown(sign)
- end
- end
- -- 6/20/2022 - v1.2
- -- All movement functions are now parts of one object. i.e., use move.forward to run the forward function().
- -- VeinMiner.lua is now loaded with require().
- -- 8/31/2021 - v1.1
- -- Fixed refuel function not checking fuel level correctly.
- -- Added code to automatically download my Vein Miner program found at: https://pastebin.com/0C6LyNES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement