Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local component = require("component")
- local sides = require("sides")
- local inventory = component.inventory_controller
- local HOE_NAME = "EMT:ElectricHoeGrowth"
- local SEED_NAME = "minecraft:wheat_seeds"
- local function equipItem(nameItem)
- if nameItem ~= nil then
- for i = 1, robot.inventorySize() do
- local item = inventory.getStackInInternalSlot(i)
- if item and item.name and item.name == nameItem then
- robot.select(i)
- inventory.equip()
- end
- end
- else
- robot.select(1)
- end
- end
- local function charge(indexItem)
- robot.turnAround()
- robot.select(indexItem)
- if(inventory.dropIntoSlot(sides.front, 1)) then
- print("charging electro item started")
- os.sleep(5)
- if(inventory.suckFromSlot(sides.front, 1)) then
- print("charging electro item finished")
- robot.turnAround()
- end
- end
- end
- local function findChargeItem(itemName)
- for i = 1, robot.inventorySize() do
- local item = inventory.getStackInInternalSlot(i)
- if item and item.name and item.name == itemName and item.charge <= 2000 then
- return charge(i)
- end
- end
- end
- local function plantSeed()
- equipItem(SEED_NAME)
- print("plant seed")
- os.sleep(0.1)
- robot.use()
- os.sleep(0.1)
- end
- local function growSeed()
- findChargeItem(HOE_NAME)
- equipItem(HOE_NAME)
- print("growth seed")
- os.sleep(0.1)
- for i = 1, 4 do
- robot.use()
- end
- os.sleep(0.1)
- end
- local function destroyWheat()
- print("destroy wheat")
- os.sleep(0.1)
- robot.swing()
- os.sleep(0.1)
- end
- local function dropItems()
- os.sleep(0.1)
- local activeSeed = false
- robot.turnRight()
- print("drop items")
- for i = 1, robot.inventorySize() do
- local item = inventory.getStackInInternalSlot(i)
- if item then
- if item.name and item.name == HOE_NAME then
- goto continue
- elseif item.label and item.name == SEED_NAME and activeSeed == false then
- activeSeed = true
- goto continue
- else
- for j = i, 20 do
- robot.select(i)
- inventory.dropIntoSlot(3, 1)
- end
- end
- end
- :: continue ::
- end
- robot.turnLeft()
- end
- while true do
- plantSeed()
- growSeed()
- destroyWheat()
- dropItems()
- end
Advertisement
Add Comment
Please, Sign In to add comment