Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------
- ----- Created by Batponney -----
- ----- On Server ComputerCraftFR -----
- --------------------------------------
- function select_next_item(slot, item)
- while slot <= 16 do
- data = turtle.getItemDetail(slot)
- if data and data.name == item then
- turtle.select(slot)
- return true
- end
- slot = slot + 1
- end
- return false
- end
- function repack_item(item)
- slot = 1
- while slot < 16 do
- data = turtle.getItemDetail(slot)
- if not data or (data.name == item and data.count < 64) then
- if select_next_item(slot + 1, item) then
- turtle.transferTo(slot)
- data = turtle.getItemDetail(slot)
- else
- return true
- end
- end
- if data and ((data.name == item and data.count == 64) or data.name ~= item) then
- slot = slot + 1
- end
- end
- return true
- end
- function scan(slot)
- data = turtle.getItemDetail(slot)
- if data then
- return data.name
- else return false
- end
- end
- function find(Name)
- slot = 1
- while slot <= 16 do
- data = turtle.getItemDetail(slot)
- if data and data.name == Name then
- turtle.select(slot)
- return true
- end
- slot = slot+1
- end
- return false
- end
- function plante(item)
- if find(item) == true then
- turtle.placeDown()
- else
- while find(item) == false do
- print("Not enought "..item.." : retrying in 5 second")
- sleep(5)
- end
- turtle.placeDown()
- end
- end
- function inspect(direction)
- if direction == "up" then
- success, data = turtle.inspectUp()
- elseif direction == "front" then
- success, data = turtle.inspect()
- elseif direction == "down" then
- success, data = turtle.inspectDown()
- end
- if success then
- return data.name
- else
- return "none"
- end
- end
- function inspectMetadata(direction)
- if direction == "up" then
- success, data = turtle.inspectUp()
- elseif direction == "front" then
- success, data = turtle.inspect()
- elseif direction == "down" then
- success, data = turtle.inspectDown()
- end
- if success then
- return data.metadata
- else
- return "none"
- end
- end
- function check()
- if inspect("down") == "minecraft:carrots" and inspectMetadata("down") == 7 then
- turtle.digDown()
- find("minecraft:carrot")
- turtle.placeDown()
- elseif inspect("down") == "minecraft:potatoes" and inspectMetadata("down") == 7 then
- turtle.digDown()
- find("minecraft:potato")
- turtle.placeDown()
- end
- end
- function coupe()
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- while inspect("up") == "minecraft:log" or inspect("up") == "minecraft:leaves" do
- turtle.digUp()
- tour = 1
- while tour <= 4 do
- turtle.dig()
- turtle.turnRight()
- tour = tour + 1
- end
- turtle.up()
- end
- while turtle.down() == true do
- turtle.down()
- end
- turtle.up()
- plante("minecraft:sapling")
- end
- function vide()
- slot = 1
- while slot <= 16 do
- turtle.select(slot)
- if scan(slot) == "minecraft:sapling" then
- turtle.dropDown(turtle.getItemCount(slot)-12)
- slot = slot + 1
- else
- turtle.dropDown()
- slot = slot + 1
- end
- end
- end
- print("Hello")
- print("Can I go ?")
- answer = read()
- if answer == "y" then
- if turtle.getFuelLevel() < 400 then
- turtle.back()
- sleep(10)
- turtle.forward()
- end
- y = 1
- state = 2
- turtle.up()
- turtle.forward()
- planted = "potato"
- while y < 26 do
- x = 1
- while x < 9 do
- if inspect("front") == "minecraft:log" then
- coupe()
- elseif inspect("front") == "minecraft:leaves" then
- turtle.dig()
- elseif inspectMetadata("down") == 7 then
- turtle.digDown()
- if planted == "potato" and find("minecraft:carrot") then
- plante("minecraft:carrot")
- planted = "carrot"
- elseif planted == "carrot" and find("minecraft:potato") then
- plante("minecraft:potato")
- planted = "potato"
- else
- if find("minecraft:potato") then
- plante("minecraft:potato")
- elseif find("minecraft:carrot") then
- plante("minecraft:carrot")
- end
- end
- end
- turtle.suckDown()
- turtle.forward()
- x = x+1
- end
- if state == 2 then
- check()
- turtle.turnLeft()
- turtle.suckDown()
- turtle.suckDown()
- turtle.forward()
- check()
- turtle.turnLeft()
- state = 1
- elseif state == 1 then
- check()
- turtle.turnRight()
- turtle.suckDown()
- turtle.forward()
- turtle.suckDown()
- check()
- turtle.turnRight()
- state = 2
- end
- y = y + 1
- end
- turtle.turnLeft()
- while turtle.forward() == true do
- turtle.suckDown()
- turtle.forward()
- end
- turtle.turnRight()
- while turtle.down() == false do
- turtle.suckDown()
- turtle.forward()
- end
- turtle.turnRight()
- turtle.turnRight()
- repack_item("minecraft:sapling")
- vide()
- os.reboot()
- elseif answer == "Maj" then
- shell.run("Maj")
- else os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement