Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Mining Program --
- function intro(quit)
- -- intro function just reads input from player to lead to menu or the help doc --
- if quit then
- print("quitting")
- return
- else
- print("-------- Mining Program --------")
- print("--------------------------------")
- print("Press H for help or S for start")
- print("You can quit typing exit")
- print(" ")
- write("--> ")
- inputhelp = string.lower(read())
- if inputhelp == "h" then
- playerhelp()
- elseif inputhelp == "exit" then
- print("quitting")
- elseif inputhelp == "s" then
- menu()
- else
- intro()
- end
- end
- end
- function playerhelp()
- -- helpfunction --
- print("HA, too bad")
- sleep(2)
- menu()
- end
- function menu()
- --prints menu, shows settings --
- term.clear()
- print("----------- Main Menu -----------")
- print("---------------------------------")
- print("--- Type in shortcuts like: T ---")
- print("--- Type exit for quitting ---")
- print(" ")
- write("Number corridors (-C) = ")
- write(corridors)
- print(" ")
- write("Length corridors (-L) = ")
- write(length)
- print(" ")
- write("Torches (-T) = ")
- write(torch)
- print(" ")
- write("Enderchest (-E) = ")
- write(ender)
- print(" ")
- write("Gap (-g) = ")
- write(gap)
- print(" ")
- write("--> ")
- playerinput = string.lower(read())
- if playerinput == "c" then
- setcorridors()
- elseif playerinput == "l" then
- setlength()
- elseif playerinput == "t" then
- settorch()
- elseif playerinput == "e" then
- setender()
- elseif playerinput == "s" then
- mainfunction()
- elseif playerinput == "g" then
- setgap()
- elseif playerinput == "exit" then
- intro(1)
- else
- menu()
- end
- end
- function setcorridors()
- write("-- set corridor number to? :")
- corridors = tonumber(read())
- menu()
- end
- function setlength()
- write("-- set corridor length to? :")
- length = tonumber(read())
- menu()
- end
- function settorch()
- write("-- Turn torches on or off? :")
- torch = read()
- menu()
- end
- function setender()
- write("-- Turn Enderchest on or off?:")
- ender = read()
- menu()
- end
- function setgap()
- write("-- set gap to?: ")
- gap = tonumber(read())
- menu()
- end
- function mainfunction()
- i=0
- while i<corridors do
- t=0
- while t<length do
- digup()
- digforward()
- turtle.forward()
- safepath()
- if torch == "on" then
- checktorch()
- end
- if ender == "on" then
- checkender()
- end
- t = t+1
- end
- turning()
- i = i+1
- end
- end
- function turning()
- if turn == 0 then
- cleanleft()
- turtle.turnLeft()
- else
- cleanright()
- turtle.turnRight()
- end
- step = 0
- while step<gap do
- digup()
- digforward()
- turtle.forward()
- step=step+1
- end
- if turn == 0 then
- turtle.turnLeft()
- turn = 1
- else
- turtle.turnRight()
- turn = 0
- end
- end
- function cleanleft()
- turtle.turnRight()
- step = 0
- while step<gap do
- digup()
- digforward()
- turtle.forward()
- step = step+1
- end
- turtle.turnRight()
- turtle.turnRight()
- for i=1,gap do
- turtle.forward()
- end
- function checkender()
- count = turtle.getItemCount(14)
- if count > 0 then
- emptyender()
- end
- end
- function emptyender()
- turtle.digUp()
- turtle.select(1)
- turtle.Up()
- turtle.placeDown()
- s = 4
- repeat
- turtle.select(s)
- turtle.dropDown()
- s = s+1
- until s>15
- turtle.digDown()
- turtle.Down()
- turtle.select(3)
- turtle.placeDown()
- end
- function checktorch()
- if torches > 10 then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(2)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- torches = 0
- else
- torches = torches+1
- end
- end
- function safepath()
- if turtle.detectDown() == false then
- select(3)
- turtle.placeDown()
- end
- end
- function digup()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.5)
- end
- end
- function digforward()
- while turtle.detect() do
- turtle.dig()
- sleep(0.5)
- end
- end
- inputs = {...} or {10,20,"On","Off","Off"}
- corridors = inputs[1] or 10
- length = inputs[2] or 20
- torch = inputs [3] or "On"
- ender = inputs [4] or "Off"
- start = inputs [5] or "Off"
- gap = 2
- torches = 0
- turn = 0
- if string.lower(start) == "on" then
- mainfunction()
- else
- intro()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement