Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- kankaku = 3
- function woodplant()
- -- 足元の穴を掘って土を置く
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- -- slot1の土を置く
- turtle.select(1)
- turtle.placeDown()
- -- slot2の木を植える
- turtle.back()
- turtle.select(2)
- turtle.place()
- end
- function storeChest()
- turtle.turnLeft()
- local success, check = turtle.inspect()
- if success and check.name == "minecraft:chest" then
- for i=3, 16 do
- turtle.select(i)
- turtle.drop()
- end
- end
- turtle.turnRight()
- end
- function woodchopper()
- turtle.dig()
- turtle.forward()
- while turtle.detectUp() do
- turtle.digUp()
- turtle.up()
- end
- while not turtle.detectDown() do
- turtle.down()
- end
- -- slot2の木を植える
- turtle.back()
- turtle.select(2)
- turtle.place()
- end
- function turnCorner()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- for k=1, kankaku do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.forward()
- -- チェストに木を格納する
- storeChest()
- end
- -- itemの確認
- slot1 = turtle.getItemDetail(1)
- if slot1 == nil then
- print("slot1 ni tuchi wo oite kudasai")
- do return end
- end
- slot2 = turtle.getItemDetail(2)
- if slot2 == nil then
- print("slot2 ni nae wo oite kudasai")
- do return end
- end
- -- 1列に植える数を質問
- io.write("ki wo ueru kazu ha?")
- x = io.read()
- -- 燃料がある限り伐採と植樹を繰り返す
- while true do
- for i=1, 2 do
- for j = 1, x do
- -- 植樹
- turtle.turnRight()
- -- slot3の木が育っているなら伐採する
- local success, check = turtle.inspect()
- if success then
- -- 苗と違うものがあったら木と判断し伐採する
- if slot2.name ~= check.name then
- woodchopper()
- end
- else
- woodplant()
- end
- turtle.turnLeft()
- -- 最終でなければ間隔を空ける
- if j ~= 5 then
- for k=1, kankaku do
- turtle.forward()
- end
- end
- end
- turnCorner()
- end
- -- 30秒後に再開
- os.sleep(30)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement