Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- cyclone3
- -- 複数回サイクロン型直下掘り
- -- ######### Config #########
- local maxDepth = 55 -- 真下に掘り進む回数
- local n = 5 -- 直下掘りする回数
- FUEL_SLOT = 1 --燃料スロット
- -- ######### Function #########
- function Fuel(num) -- 燃料補給の際、燃料がある一定量以下の場合のみ給油する
- turtle.select(1)
- local limit = 2000
- local fuel = turtle.getFuelLevel()
- print (fuel)
- if tonumber(fuel) <= tonumber(limit) then
- r,e = turtle.refuel(num)
- print (e)
- else
- print (fuel)
- end
- end
- function kaitenChokkabori(shita) -- shita回だけ回転直下掘り
- local countDepth = 0
- for i=1,shita do
- for j=1,4 do -- 一回転しつつ正面採掘
- turtle.turnLeft()
- turtle.dig()
- end
- turtle.digDown() -- 直下掘りして真下移動
- if turtle.down() then -- タートルが下に移動した分だけカウント
- countDepth = countDepth + 1
- else
- break -- これ以上下がる必要がないのでbreak
- end
- end
- return countDepth
- end
- function backToHome(ue) -- ue回だけ上昇する
- for i=1,ue do
- turtle.up()
- end
- end
- function inChest(...)
- for i=2,16 do --スロット1の燃料は預けない
- turtle.select(i)
- r,e = turtle.dropDown() --rはtrueかfalseを返してくれる
- print (e)
- end
- end
- -- ######### Main #########
- -- 直下掘り
- Fuel(((maxDepth*2 + 3 * n*(n+1))/80) + 1) -- 必要分を引数に燃料補給
- local count = 1
- -- 以下をn回繰り返す
- for i=1,n do
- -- チェストから収穫ポイントまで移動する
- for j=1,count do
- turtle.forward()
- turtle.forward()
- turtle.forward()
- end
- -- 回転直下掘り
- local depth = kaitenChokkabori(maxDepth)
- print("depth: ", depth)
- backToHome(depth)
- -- 一旦地上に戻ってきたら、チェストまで戻る
- turtle.turnLeft()
- turtle.turnLeft()
- for j=1,count do
- turtle.forward()
- turtle.forward()
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- -- アイテムをチェストにしまう
- inChest()
- count = count + 1
- end
- -- ######### Todo #########
- -- 例外処理, エラー処理
- -- プレイヤーと衝突したときなど
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement