Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("branch no kazu ha?")
- local tunnelNumber = read() -- ブランチの数を入力
- print("Branch no nagasa ha?( kojinteki niha nagakute mo 10 guraikana")
- local tunnelLength = read()
- print("kyori ha? 3 gurai ga best")
- local tunnelWall = read()
- print("Slot2 ni Toatch wo oite kudasai. jyunbi gadekitara enter site kudasai")
- read()
- local mainDistance = 0
- local sideDistance = 0
- local mainLength = tunnelNumber*(tunnelWall+1)
- local totalTravel = (4*tunnelLength)*(tunnelNumber+2)+(mainLength*2)
- print("Hituyou na nenryou : "..totalTravel)
- sleep(2)
- function sideWork(dist) -- 横のトンネルを作る, トンネルの距離を引数にする
- for i=1,dist do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- sideDistance = sideDistance +1
- turtle.digDown()
- turtle.digUp()
- end
- end
- function mainWork(dist) -- メインのトンネルを作る, トンネルの長さを引数にする
- for i=1,dist do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- mainDistance = mainDistance + 1
- turtle.digDown()
- turtle.digUp()
- end
- end
- function travel(dist) -- turtle.forward で掘る必要がないところをスキップ、または強制停止か、敵にぶつかったりとか.
- for i=1, dist do
- repeat
- until turtle.forward() == true
- end
- end
- function spin() -- なぜなら、これ以上無理だから
- turtle.turnRight()
- turtle.turnRight()
- end
- function noFuel() -- 全体の燃料を計算し必要とする燃料の数を返却
- if turtle.getFuelLevel() < totalTravel then
- return true
- end
- end
- function placeTorch() -- Slot2にトーチを設定
- turtle.select(2)
- turtle.placeUp()
- turtle.select(1)
- end
- function checkInventory() -- インベントリを確認
- if turtle.getItemCount(15) > 0 then
- return true
- end
- end
- function goHome() -- メイントンネルからスタートの位置へ戻る
- spin()
- travel(mainDistance)
- end
- function goToMain() -- メインのトンネルへ戻る
- spin()
- travel(sideDistance)
- end
- function main(number,length,wall) -- さぁ、掘りまくろう
- if noFuel() == true then
- print("motto nenryo kudasai "..totalTravel - turtle.getFuelLevel().." ga hituyou desu.")
- end
- while noFuel() do -- もしん燃料がないなら, スロット1に燃料があるかたしかめ、あるなら補給
- turtle.select(1)
- turtle.refuel()
- sleep(0.5)
- end
- for i=1,number do -- トンネルを掘るために何度も繰り返す
- mainWork(wall+1)
- turtle.back()
- placeTorch()
- turtle.forward()
- turtle.turnRight()
- sideWork(length)
- placeTorch()
- spin()
- travel(length)
- sideDistance = 0
- sideWork(length)
- placeTorch()
- spin()
- travel(length)
- turtle.turnLeft()
- if checkInventory() then -- スロットに空きがないなら一旦ホームにもどって集めたブロックを捨てる
- goHome()
- turtle.select(1)
- turtle.drop()
- for slot=3,16 do
- turtle.select(slot)
- turtle.drop()
- end
- turtle.select(1)
- spin()
- travel(mainDistance)
- end
- end
- goHome()
- for slot=1,16 do
- turtle.select(slot)
- turtle.drop()
- end
- print("branch kansei tugi ha dousuru?")
- end
- main(tunnelNumber,tunnelLength,tunnelWall)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement