Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component");
- local robot_api = require("robot");
- local computer = require("computer");
- local sides = require("sides");
- local inventory = component.inventory_controller;
- --local robot = component.robot;
- local geolyzer = component.geolyzer;
- local redstone = component.redstone;
- local iron_scaffold = "ic2:scaffold";
- local foam = "ic2:foam";
- local reinforced_stone = "ic2:resource";
- local air = "minecraft:air";
- local sand = "minecraft:sand";
- local iron_scaffol_inventory_number = 3 +5;
- local reinforced_stone_inventory_number = 1;
- local sand_inventory_number = 4 +5;
- local bore_inventory_number = 2 +5;
- local spray_inventory_number = 1 +5;
- local sand_slot = 4;
- local scaffold_slot = 7;
- local stone_slot = 1;
- local function isBlock(name)
- local info_from_geolyzer = geolyzer.analyze(sides.forward);
- if (info_from_geolyzer.name == name)
- then return true
- else return false
- end
- end
- local function placeIronScaffold()
- robot_api.select(iron_scaffol_inventory_number);
- result_of_placing = robot_api.place();
- return result_of_placing;
- end
- local function foamTheScaffold()
- robot_api.select(spray_inventory_number);
- inventory.equip();
- result_of_foaming = robot_api.use();
- inventory.equip();
- return result_of_foaming;
- end
- local function useSandOnFoam()
- robot_api.select(sand_inventory_number);
- inventory.equip();
- result_of_sanding = robot_api.use();
- inventory.equip();
- return result_of_sanding;
- end
- local function boreTheStone()
- robot_api.select(bore_inventory_number);
- inventory.equip();
- result = robot_api.swing();
- inventory.equip();
- return result;
- end
- local function refuelSprayer()
- print("spray_refuel");
- robot_api.select(spray_inventory_number);
- inventory.equip();
- robot_api.turnAround();
- robot_api.use();
- robot_api.turnAround();
- inventory.equip();
- end;
- local function isEnergyBelow30Procent()
- local max_energy = computer.maxEnergy();
- local current_energy = computer.energy();
- local current_energy_in_procents = (current_energy * 100) / max_energy;
- return current_energy_in_procents;
- end
- local function chargeUp()
- redstone.setOutput(sides.right, 15);
- while (true) do
- os.sleep(2);
- if (computer.energy() >= (computer.maxEnergy()*0.9)) then break; end;
- end
- redstone.setOutput(sides.right, 0);
- end
- local function takeSandAndScaffoldFromExternalInventory()
- robot_api.select(sand_inventory_number);
- inventory.suckFromSlot(sides.down, sand_slot);
- robot_api.select(iron_scaffol_inventory_number);
- inventory.suckFromSlot(sides.down, scaffold_slot);
- end
- local function isOutOfMaterials()
- robot_api.select(sand_inventory_number);
- local stack = inventory.getStackInInternalSlot();
- if (stack == nil)
- then return true;
- end;
- local size = stack.size;
- if (size <= 0) then return true; end;
- return false;
- end
- local function isStoneFull()
- robot_api.select(reinforced_stone_inventory_number);
- local stack = inventory.getStackInInternalSlot();
- if (stack == nil)
- then return false;
- end;
- local size = stack.size;
- if (size >= 1) then return true; end;
- return false;
- end
- local function getRidOfStone()
- for i=1, 8, 1
- do
- local item = inventory.getStackInInternalSlot(i);
- if (item)
- then
- if (item.name == reinforced_stone)
- then
- inventory.dropIntoSlot(sides.down, stone_slot);
- end;
- end;
- end;
- end;
- local function main()
- chargeUp();
- local remaining_foam = 80;
- while (true) do
- if (isEnergyBelow30Procent() == true)
- then chargeUp();
- end;
- if (isOutOfMaterials() == true)
- then takeSandAndScaffoldFromExternalInventory();
- end;
- if (remaining_foam <= 0)
- then
- print(remaining_foam);
- refuelSprayer();
- remaining_foam = 80;
- getRidOfStone();
- inventory.equip();
- getRidOfStone();
- inventory.equip();
- end;
- robot_api.select(iron_scaffol_inventory_number);
- if (isBlock(air) == true)
- then placeIronScaffold();
- end;
- if (isBlock(iron_scaffold) == true)
- then
- if (foamTheScaffold() == true)
- then
- remaining_foam = remaining_foam - 1;
- else refuelSprayer(); remaining_foam = 80;
- end;
- end;
- if (isBlock(foam) == true)
- then useSandOnFoam();
- end;
- if (isBlock(reinforced_stone) == true)
- then boreTheStone();
- end;
- end;
- end;
- main();
- --refuelSprayer();
Add Comment
Please, Sign In to add comment