Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- tofu3
- -- 豆腐建築を行うプログラムです
- -- アイテムインベントリに適当にアイテム詰めて
- -- 燃料はもちろんたっぷり与えておくこと
- -- ####### Config ###########
- local haba = 15
- local okuyuki = 12
- local takasa = 5
- local togariyane = true -- true or false
- -- ####### Functions ########
- -- #####
- -- アイテムインベントリ用の関数群
- -- 次のアイテムスロットへ選択スロットを移動
- function selectNextSlot()
- local current = turtle.getSelectedSlot()
- if current == 16 then
- return false
- else
- turtle.select(current+1)
- return true
- end
- end
- -- 選択スロットを次のアイテムのあるスロットまで移動
- function selectNextItemSlot()
- while (turtle.getItemCount()==0) and selectNextSlot() do
- end
- end
- -- インベントリを先頭から走査し、確実にアイテムを真下設置
- function myPlaceDown()
- while (turtle.getItemCount()==0) and selectNextItemSlot() do
- print("Current slot:",turtle.getSelectedSlot())
- end
- return turtle.placeDown()
- end
- -- #####
- -- 建築用の関数
- local usedBlocks = 0
- -- 前進しつつn個のブロックを下に設置
- function placeSomeBlocks(n)
- if n<1 then -- 最後の真下の穴を埋める
- if myPlaceDown() then
- usedBlocks = usedBlocks+1
- end
- return
- end
- for i=1,n do -- n個並べる
- turtle.forward()
- if myPlaceDown() then
- usedBlocks = usedBlocks+1
- end
- end
- end
- -- ロの字にブロックを設置
- function buildRonoji(okuyuki, haba)
- for i=1,2 do
- placeSomeBlocks(okuyuki - 1)
- turtle.turnRight()
- placeSomeBlocks(haba - 1)
- turtle.turnRight()
- end
- end
- -- 屋根の次の位置に移動
- function goToRightForward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- end
- function goToLeftBack()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.back()
- end
- function goUp()
- if togariyane then
- turtle.up()
- end
- end
- -- ###### Main ########
- turtle.select(1) -- 最初の決まり文句
- turtle.up() -- 一歩上昇して、設置位置につく
- -- ロの字を1段ずつ takasa まで積み上げる
- for ronoji=1,takasa do
- buildRonoji(okuyuki, haba)
- turtle.up() -- move up
- end
- -- とがり屋根だと、ひさしを作る
- -- 一回り大きなロの字を作る
- if togariyane then
- goToLeftBack()
- buildRonoji(okuyuki+2, haba+2)
- goToRightForward()
- buildRonoji(okuyuki, haba)
- turtle.up()
- end
- -- 屋根作り
- -- 少しずつ小さなロの字を敷き詰める。
- while (okuyuki > 0) and (haba > 0) do
- buildRonoji(okuyuki, haba)
- goToRightForward()
- goUp() -- とがり屋根だと1歩上昇
- okuyuki = okuyuki - 2
- haba = haba - 2
- end
- print("Used Blocks:", usedBlock)
- -- redstone.setOutput("bottom",true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement