Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- debug = true
- term.clear()
- term.setCursorPos(1,1)
- print("===============================")
- print("Welcome to MineHall - 7.0")
- print("(c)2019 Lilkingjr13 & NGXII")
- print("===============================")
- print("")
- print("How long do you want your hall to be?:")
- length = read()
- print("How wide do you want your hall to be?:")
- width = read()
- print("How tall do you want your hall to be?:")
- height = read()
- print("Would you like to place torches? (Y/N):")
- print("(Put torches in 1st slot of Turtle)")
- torch = read()
- if torch == "yes" or torch == "y" or torch == "Y" then
- print("How often to place a torch?")
- print("Every ? blocks...")
- torchfreq= read()
- --Check for valid number for torch frequency
- while tonumber(torchfreq) == nil or tonumber(torchfreq)< 1 do
- print("Incorrect Parameter - Please Enter a NUMBER greater than 0")
- torchfreq = read()
- end
- else
- torch = false
- end
- print("Press enter to start mining... (Enter x to terminate)")
- go = read()
- if go == "x" then
- error()
- end
- --Variable Definition
- --Check for valid number for length
- while tonumber(length) == nil or tonumber(length) < 1 do
- print("Incorrect Length Parameter - Please Enter a NUMBER greater than 0")
- length = read()
- end
- --Check for valid number for width
- while tonumber(width) == nil or tonumber(width) < 1 do
- print("Incorrect Width Parameter - Please Enter a NUMBER greater than 0")
- width = read()
- end
- --Check for valid number for height
- while tonumber(height) == nil or tonumber(height) < 1 do
- print("Incorrect Height Parameter - Please Enter a NUMBER greater than 0")
- height = read()
- end
- length = tonumber(length)
- width = tonumber(width-1)
- height= tonumber(height)
- if torch == "yes" then
- torch = true
- torchfreq = tonumber(torchfreq)
- else
- torch = false
- end
- left = false --”left” determines if its on the left side of the mine
- origin = true --determines if at origin
- going = true --determines if going away from the origin
- done = false --determines if done with program
- blockCount = 0 --Counts blocks successfully mined
- moveCount = 0 --Counts successful forward moves
- --Define Functions
- function mine()
- if height == 1 then
- if turtle.dig() then
- blockCount = blockCount + 1
- end
- elseif height == 2 then
- if turtle.dig() then
- blockCount = blockCount + 1
- end
- if turtle.digUp() then
- blockCount = blockCount + 1
- end
- elseif height > 2 then
- if turtle.dig() then
- blockCount = blockCount + 1
- end
- if turtle.digUp() then
- blockCount = blockCount + 1
- end
- if turtle.digDown() then
- blockCount = blockCount + 1
- end
- else
- print("Incorrect Height Parameter")
- if debug == true then
- print("Error at mine()")
- end
- end
- end
- function advance()
- result = turtle.forward()
- if result == false then
- if debug == true then print("I can't move!") end
- fuel = turtle.getFuelLevel()
- if fuel == 0 then
- if debug == true then print("I'm out of fuel!") end
- turtle.refuel(3)
- if debug == true then print("I refuelled") end
- else
- if debug == true then print("I have hit an obstacle!") end
- mine()
- end
- advance()
- else
- if debug == true then print("I moved!") end
- end
- end
- function mineLayer()
- if origin == true then
- turtle.turnLeft()
- if height > 2 then
- turtle.digUp()
- eres = turtle.up()
- if eres == false then
- turtle.refuel(3)
- turtle.up()
- end
- end
- for i=0, tonumber((width/2)-1) do
- mine()
- advance()
- end
- origin = false
- turtle.turnRight()
- left = true
- else
- mine()
- advance()
- --Turn to start mining
- if left == true then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- --Mine Forward
- for i=1, width do
- mine()
- advance()
- moveCount = moveCount + 1
- end
- --Flip the left variable
- if left == true then
- left = false
- else
- left = true
- end
- --Turn
- if left == true then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- end
- function escalate(upNum)
- --Turn around
- turtle.dig()
- advance()
- turtle.turnLeft()
- turtle.turnLeft()
- for uCount=1, upNum do
- turtle.digUp()
- eres = turtle.up()
- if eres == false then
- turtle.refuel(3)
- turtle.up()
- end
- if debug == true then print("escalated") end
- end
- --Flop the left variable
- if left == true then
- left = false
- else
- left = true
- end
- --Flip the direction variable
- if going == true then
- going = false
- else
- going = true
- end
- end
- function home()
- --Turn To Center
- if left == true then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- mine()
- --Move to Center
- for move=0, ((width/2) -1) do
- advance()
- end
- --Turn To Home
- if left == true then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- --Check for which end of mine
- if going == false then
- for walk = 0, (length-1) do
- advance()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- --Drop to second to bottom layer
- for i=0, (height-4) do
- turtle.down()
- end
- --Go Home
- for i=0, (length-1) do
- advance()
- if torch then
- if (i % torchfreq) == 0 then
- turtle.placeDown()
- end
- end
- end
- end
- function mineSlab()
- for count=0, (length) do
- mineLayer()
- count = count + 1
- end
- end
- --START PROGRAM
- print("Starting Mining")
- if height < 4 then
- mineSlab()
- else
- for repeats=1, ((height/3)-1) do
- mineSlab()
- escalate(3)
- end
- mineSlab()
- rem = (height%3)
- escalate(rem)
- mineSlab()
- end
- home()
- done = true
- --Print End Results
- print("Successfuly mined a "..width.."x"..length.."x"..height.." cube!")
- print("And collected a total of "..blockCount.." items!")
- print("Mining Complete.")
- --End Program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement