Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local currPos=-2
- local tunnel=2
- local lavaRefuel=1
- local tblWallBlocks={"minecraft:cobblestone", "minecraft:stone", "minecraft:dirt", "minecraft:netherrack", "minecraft:basalt", "minecraft:blackstone", "extcaves:lavastone", "astralsorcery:blockcustomore", "create:weathered_limestone", "quark:deepslate", "quark:cobbled_deepslate", "minecraft:deepslate", "minecraft:cobbled_deepslate", "minecraft:tuff", "byg:soapstone", "byg:scoria_stone", "byg:scoria_cobblestone"}
- local tblPlaceBlocks={"minecraft:cobblestone", "minecraft:dirt", "minecraft:netherrack", "extcaves:lavastone", "minecraft:basalt", "minecraft:blackstone", "create:weathered_limestone", "quark:deepslate", "quark:cobbled_deepslate", "minecraft:deepslate", "minecraft:cobbled_deepslate", "minecraft:tuff", "byg:soapstone", "byg:scoria_stone", "byg:scoria_cobblestone"}
- local tblRareBlocks={"minecraft:diamond_ore","minecraft:gold_ore","minecraft:iron_ore","minecraft:deepslate_diamond_ore","minecraft:deepslate_gold_ore","minecraft:deepslate_iron_ore","minecraft:ancient_debris","minecraft:nether_quartz_ore","rftoolsbase:dimensionalshard_nether","tconstruct:cobalt_ore"}
- function inTable(tbl, item)
- for i, v in ipairs(tbl) do
- if v == item then
- return true
- end
- end
- return false
- end
- function moveForw()
- local try=1
- while not turtle.forward() do
- prntMiningScreen("I can't go forward .. try:"..try)
- sleep(1)
- try=try+1
- end
- end
- function moveBack()
- local try=1
- while not turtle.back() do
- prntMiningScreen("I can't go back .. try:"..try)
- sleep(1)
- try=try+1
- end
- end
- function moveUp()
- local try=1
- while not turtle.up() do
- prntMiningScreen("I can't go up .. try:"..try)
- sleep(1)
- try=try+1
- end
- end
- function moveDown()
- local try=1
- while not turtle.down() do
- prntMiningScreen("I can't go down .. try:"..try)
- sleep(1)
- try=try+1
- end
- end
- function turnL()
- turtle.turnLeft()
- end
- function turnR()
- turtle.turnRight()
- end
- function turn2()
- turnR()
- turnR()
- end
- function checkWallStone(ws)
- local success, data
- if ws=="forw" then
- success, data = turtle.inspect()
- elseif ws=="up" then
- success, data = turtle.inspectUp()
- elseif ws=="down" then
- success, data = turtle.inspectDown()
- end
- if success then
- if lavaRefuel==1 then
- if data.name=="minecraft:lava" then
- refuelLava(ws)
- end
- end
- if (inTable(tblWallBlocks, data.name)) then
- return("wallBlocks")
- elseif (inTable(tblRareBlocks, data.name)) then
- return("rareBlocks")
- else
- return(0)
- end
- end
- end
- function digForw(ws)
- if ws~="wallBlocks" then
- while turtle.detect() do
- turtle.dig()
- end
- end
- end
- function digDown(ws)
- if ws~="wallBlocks" then
- turtle.digDown()
- end
- end
- function digUp(ws)
- if ws~="wallBlocks" then
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- end
- function placeForw(ws)
- if not turtle.detect() then
- A=placeStone()
- if A==1 then
- if ws~="rareBlocks" then
- local try=1
- while not turtle.place() do
- prntMiningScreen("I can't place forw. a block !..Try: "..try)
- try=try+1
- sleep(1)
- end
- end
- end
- end
- end
- function placeUp(ws)
- if not turtle.detectUp() then
- A=placeStone()
- if A==1 then
- if ws~="rareBlocks" then
- local try=1
- while not turtle.placeUp() do
- prntMiningScreen("I can't place up. a block !..Try: "..try)
- try=try+1
- sleep(1)
- end
- end
- end
- end
- end
- function placeDown(ws)
- if not turtle.detectDown() then
- A=placeStone()
- if A==1 then
- if ws~="rareBlocks" then
- local try=1
- while not turtle.placeDown() do
- prntMiningScreen("I can't place down. a block !..Try: "..try)
- try=try+1
- sleep(1)
- end
- end
- end
- end
- end
- function placeStone()
- for A=1,16 do
- local item=turtle.getItemDetail(A)
- if item then
- if (inTable(tblPlaceBlocks, item.name)) then
- turtle.select(A)
- return(1)
- end
- end
- if A==16 then
- return(0)
- end
- end
- end
- function setChest()
- turnL()
- moveForw()
- moveDown()
- moveDown()
- turnL()
- setChest2()
- turnL()
- setChest2()
- moveUp()
- moveUp()
- moveForw()
- turnL()
- setTorch()
- end
- function setChest2()
- for A=1,16 do
- local item=turtle.getItemDetail(A)
- if item then
- if (item.name=="minecraft:chest") then
- turtle.select(A)
- if turtle.detect() then turtle.dig() end
- turtle.place()
- break
- end
- end
- end
- end
- function goToPos()
- for A=1, currPos do
- moveForw()
- end
- turnR()
- moveForw()
- turnL()
- moveUp()
- moveUp()
- end
- function gotoChest()
- moveDown()
- moveDown()
- turnL()
- moveForw()
- turnL()
- for A=1,currPos do
- moveForw()
- end
- end
- function invFull()
- local full=0
- local blocks=0
- for A=1,16 do
- if turtle.getItemCount(A)>0 then
- full=full+1
- local item=turtle.getItemDetail(A)
- if (inTable(tblPlaceBlocks, item.name)) then
- blocks=blocks+turtle.getItemCount(A)
- end
- end
- end
- if full>14 or blocks<12 then
- gotoChest()
- emptyInv()
- goToPos()
- end
- end
- function emptyInv()
- turnL()
- for A=1,16 do
- local item=turtle.getItemDetail(A)
- if item then
- if (inTable(tblPlaceBlocks, item.name)) then
- turtle.select(A)
- turtle.drop()
- end
- end
- end
- turnR()
- for A=1,16 do
- local item=turtle.getItemDetail(A)
- if item then
- if (item.name~="minecraft:coal") and (item.name~="minecraft:torch") and (item.name~="minecraft:bucket") and (item.name~="tconstruct:stone_torch") then
- turtle.select(A)
- turtle.drop()
- elseif item.name=="minecraft:coal" then
- if turtle.getFuelLevel()<1000 then
- turtle.select(A)
- turtle.refuel(20)
- end
- end
- end
- end
- local try=1
- while turtle.getFuelLevel()<1000 do
- if turtle.refuel(20) then break end
- prntMiningScreen("I need coal. please put some coal in the selected slot..! try: "..try)
- try=try+1
- sleep(2)
- end
- turnL()
- turtle.suck()
- local slot=0
- while true do
- slot=slot+1
- local item=turtle.getItemDetail(slot)
- if item then
- if (inTable(tblPlaceBlocks, item.name)) then
- break
- end
- end
- if slot==16 then
- prntMiningScreen("I need some cobblestone, dirt, or netherrack...! try: "..try)
- try=try+1
- slot=0
- sleep(2)
- end
- end
- turnL()
- end
- function buildTunnel()
- local ws=0
- digForw(0)
- moveForw()
- turnL()
- ws=checkWallStone("up")
- digUp(ws)
- placeUp(ws)
- if tunnel==1 then
- digForw(0)
- moveForw()
- placeDown(0)
- digDown(0)
- ws=checkWallStone("up")
- digUp(ws)
- placeUp(ws)
- end
- digForw(0)
- moveForw()
- ws=checkWallStone("up")
- digUp(ws)
- placeUp(ws)
- ws=checkWallStone("forw")
- digForw(ws)
- placeForw(ws)
- digDown(0)
- moveDown()
- ws=checkWallStone("forw")
- digForw(ws)
- placeForw(ws)
- digDown(0)
- moveDown()
- ws=checkWallStone("forw")
- digForw(ws)
- placeForw(ws)
- ws=checkWallStone("down")
- digDown(ws)
- placeDown(ws)
- turn2()
- if tunnel==1 then
- digForw(0)
- moveForw()
- ws=checkWallStone("down")
- digDown(ws)
- placeDown(ws)
- end
- digForw(0)
- moveForw()
- ws=checkWallStone("down")
- digDown(ws)
- placeDown(ws)
- ws=checkWallStone("forw")
- digForw(ws)
- placeForw(ws)
- digUp(0)
- moveUp()
- ws=checkWallStone("forw")
- digForw(ws)
- placeForw(ws)
- digUp(0)
- moveUp()
- ws=checkWallStone("forw")
- digForw(ws)
- placeForw(ws)
- turnL()
- currPos=currPos+1
- end
- function setTorch()
- turnL()
- if tunnel==1 then moveForw() end
- for A=1,16 do
- local item=turtle.getItemDetail(A)
- if item then
- if (item.name=="minecraft:torch") or (item.name=="tconstruct:stone_torch") then
- turtle.select(A)
- if turtle.detect() then turtle.dig() end
- turtle.place()
- break
- end
- end
- end
- if tunnel==1 then moveBack() end
- turnR()
- end
- function refuel()
- if turtle.getFuelLevel()<500 then
- for A=1, 16 do
- local item=turtle.getItemDetail(A)
- if item then
- if item.name=="minecraft:coal" then
- turtle.select(A)
- turtle.refuel(10)
- if turtle.getFuelLevel()>500 then break
- end
- end
- end
- if A==16 then
- gotoChest()
- emptyInv()
- goToPos()
- end
- end
- end
- end
- function refuelLava(ws)
- for A=1, 16 do
- local item=turtle.getItemDetail(A)
- if item then
- if item.name=="minecraft:bucket" then
- turtle.select(A)
- if ws=="forw" then
- turtle.place()
- elseif ws=="up" then
- turtle.placeUp()
- elseif ws=="down" then
- turtle.placeDown()
- end
- turtle.refuel()
- break
- end
- end
- end
- prntMiningScreen(0)
- end
- function prntScreen()
- term.clear()
- term.setCursorPos(1,1)
- print("Choose your options")
- print("")
- print("1: main tunnel, 3 m wide ")
- print("2: sec. tunnel, 2 m wide ")
- if tunnel==1 then
- term.setCursorPos(26,3)
- elseif tunnel==2 then
- term.setCursorPos(26,4)
- end
- term.write("<<<<")
- term.setCursorPos(1,6)
- print("required materials: 8 torches, 2 chests and some fillblocks (e.g. cobblestone)")
- local lr="active)"
- if lavaRefuel==0 then
- lr="inactive)"
- end
- term.setCursorPos(1,10)
- print("r: to toggle lava refuel from world, a bucket will be needed ("..lr)
- term.setCursorPos(1,13)
- term.write("Enter: to start")
- end
- function prntMiningScreen(msg)
- term.clear()
- term.setCursorPos(13,2)
- print("WIMOS MINER")
- term.setCursorPos(29,4)
- term.write("Fuel: " .. turtle.getFuelLevel())
- if msg~=0 then
- term.setCursorPos(1,10)
- print(msg)
- end
- end
- function main()
- prntScreen()
- while true do
- local check,key=os.pullEvent("key")
- if check then
- if key >= 320 and key <= 329 then key = key - 272 end -- numpads
- if key==keys.enter then
- prntMiningScreen(0)
- break
- elseif key==keys.w or key == 265 or key == 49 then
- tunnel=1
- prntScreen()
- elseif key==keys.s or key == 264 or key == 50 then
- tunnel=2
- prntScreen()
- elseif key==keys.r then
- lavaRefuel=(lavaRefuel-1)*(-1)
- prntScreen()
- end
- end
- end
- end
- main()
- digUp(0)
- moveUp()
- digUp(0)
- moveUp()
- buildTunnel()
- buildTunnel()
- setChest()
- for A=1,7 do
- for B=1,(5+(tunnel-1)*2) do
- buildTunnel()
- refuel()
- invFull()
- end
- setTorch()
- end
- for A=0,2 do buildTunnel() end
- gotoChest()
- emptyInv()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement