Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local drone = component.proxy(component.list("drone")());
- local link = component.proxy(component.list("tunnel")());
- local scanner = component.proxy(component.list("geolyzer")());
- local inv = component.proxy(component.list("inventory_controller")());
- num = 0;
- drone.setLightColor(0x800080);
- version = "3.5";
- xOff = 0;
- yOff = 0;
- zOff = 0;
- farmW = 9;
- farmH = 9;
- xOffTemp = 1;
- yOffTemp = 1;
- lastCrop = "minecraft:wheat";
- previousBlock = 0;
- function scanInventory(itemName)
- for i=1, 8, 1 do
- slotData = inv.getStackInInternalSlot(i);
- if slotData == nil then t = 0
- elseif slotData.name == itemName then return i end
- end
- end
- run = true;
- lightStartingUp = 0x2550200;
- lightIdle = 0x2552510;
- lightMoving = 0x025542;
- dirX = 1;
- dirY = 1;
- function setStatus(status)
- drone.setStatusText(status);
- end
- function move(x, y, z);
- setColor(lightMoving);
- drone.move(x, y, z);
- xOff = xOff + x;
- yOff = yOff + y;
- zOff = zOff + z;
- setColor(lightIdle);
- end
- function setColor(light)
- drone.setLightColor(light);
- end
- function nextGridSpace()
- if xOffTemp < farmW then
- move(dirX, 0, 0)
- xOffTemp = xOffTemp + 1;
- elseif xOffTemp == farmW then
- if yOffTemp == 9 then
- dirY = dirY * -1;
- dirX = dirX * -1;
- yOffTemp = 1;
- xOffTemp = 1;
- else
- move(0, 0, dirY);
- yOffTemp = yOffTemp + 1;
- xOffTemp = 1;
- dirX = dirX * -1;
- end
- end
- end
- function scan()
- data = scanner.analyze(0);
- if data.name == "minecraft:air" then t = 0
- else lastCrop = data.name;
- end
- return data.growth;
- end
- function wait(freq)
- computer.pullSignal(freq);
- end
- move(0, 1, 0)
- link.send("CONNECTED");
- function plantSeeds()
- if lastCrop == "minecraft:wheat" then place("minecraft:wheat_seeds")
- elseif lastCrop == "minecraft:potatoes" then place("minecraft:potato")
- elseif lastCrop == "minecraft:carrots" then place("minecraft:carrot");
- end
- end
- function place(item)
- drone.select(scanInventory(item))
- drone.place(0);
- drone.select(1);
- end
- function collect()
- for i=0, 5, 1 do
- drone.suck(i);
- end
- end
- function harvest()
- drone.swing(0);
- collect();
- end
- function checkBlock()
- data = scanner.analyze(0);
- name = data.name;
- if name ~= "minecraft:water" then
- move(0, -1, 0)
- drone.place(0);
- wait(.5);
- move(0, 1, 0);
- wait(.3)
- plantSeeds();
- wait(.5)
- else move(0, 1, 0);
- end
- end
- function storeItems()
- side = 0;
- for i=0, 5, 1 do
- block = scanner.analyze(i)
- if block.name == "minecraft:chest" then
- side = i;
- break;
- end
- end
- for i=2, 8, 1 do
- drone.select(i)
- drone.drop(side);
- end
- drone.select(1);
- end
- function recharge()
- storeItems();
- setStatus("RECHARGING");
- wait(5);
- end
- while run == true do
- grow = scan();
- if grow == nil then checkBlock();
- elseif grow == 1 then
- harvest();
- plantSeeds();
- end;
- if yOffTemp == 9 and xOffTemp == 9 then
- recharge();
- end
- wait(.5);
- setStatus(lastCrop);
- nextGridSpace();
- end
Add Comment
Please, Sign In to add comment