Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin run Pc6MGrfZ
- local robot = require("robot")
- local comp = require("computer")
- local component = require("component")
- local sides = require("sides")
- local item = component.inventory_controller
- slotrobot = robot.inventorySize()
- colvo = 16
- needseeds = 256
- robot.select(1)
- function go()
- slot = slotget(1)
- if slot["name"] ~= "minecraft:wheat_seeds" then
- seed()
- end
- status = robot.forward()
- robot.swingDown()
- robot.placeDown()
- return status
- end
- function slotget(idslot)
- idslot = tonumber(idslot)
- if item.getStackInInternalSlot(idslot) ~= nil then
- get = item.getStackInInternalSlot(idslot)
- resp = {name = get.name, size = get.size}
- else
- resp = {name = "none", size = 0}
- end
- return resp
- end
- function clearinv()
- print("use clearinv()")
- for i = 1, slotrobot do
- slot = slotget(i)
- if slot["name"] ~= "minecraft:wheat_seeds" and slot["name"] ~= "minecraft:wheat" and slot["name"] == "none" then
- robot.select(i)
- robot.dropDown()
- print("Мусора удален слоте:", i)
- else
- print("Мусора нет в слоте:", i)
- end
- end
- end
- function seed()
- print("use seed()")
- robot.select(1)
- slot1 = slotget(1)
- if slot1["name"] ~= "minecraft:wheat_seeds" then
- for i = 2, slotrobot do
- getslot = slotget(i)
- if getslot["name"] == "minecraft:wheat_seeds" and getslot["size"] + slot1["size"] <= 64 or getslot["size"] == 0 then
- robot.transferTo(i)
- end
- end
- end
- if slot1["size"] == 0 then
- for i = 1, slotrobot do
- getslot = slotget(i)
- if getslot["name"] == "minecraft:wheat_seeds" then
- robot.select(i)
- if slot1["size"] < 64 then
- robot.transferTo(1)
- end
- end
- end
- end
- robot.select(1)
- end
- function gotohome()
- print("use gotohome()")
- robot.turnRight()
- repeat
- status = robot.forward()
- until status == nil
- robot.turnRight()
- robot.forward()
- end
- function clearinvwheat()
- print("use clearinvwheat()")
- seeds = 0
- print(slotrobot)
- for i = 1, slotrobot do
- getslot = slotget(i)
- print(getslot["size"])
- if getslot["name"] == "minecraft:wheat" then
- robot.select(i)
- robot.drop()
- end
- end
- clearinv()
- for i = 1, slotrobot do
- getslot = slotget(i)
- if seeds >= needseeds then
- robot.select(i)
- robot.drop()
- end
- slotsize = getslot["size"]
- seeds = seeds + slotsize
- print("кол-во семян:",seeds)
- end
- robot.select(1)
- robot.turnRight()
- robot.turnRight()
- end
- function work()
- print("use work()")
- repeat
- go()
- until status == nil
- end
- function worked()
- print("use worked()")
- for i = 1, colvo/2 do
- print(i)
- work()
- robot.turnLeft()
- robot.forward()
- robot.turnLeft()
- robot.swingDown()
- robot.placeDown()
- work()
- robot.turnRight()
- robot.forward()
- robot.turnRight()
- robot.swingDown()
- robot.placeDown()
- end
- end
- while true do
- -- one hour sleeping
- print("НАЧАЛО")
- clearinv()
- robot.select(1)
- seed()
- worked()
- gotohome()
- clearinvwheat()
- print("Ожидание")
- for i=1, 10 do
- print((10*i)..'%')
- os.sleep(360)
- end
- end
Add Comment
Please, Sign In to add comment