Created
July 10, 2018 21:08
-
-
Save MEXAHOTABOP/5b18f11eede6c720976f8a0ad211c35e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| os = require("os") | |
| comp = require("component") | |
| side = require("sides") | |
| robot= require("robot") | |
| cmp = require("computer") | |
| inv_c= comp.inventory_controller | |
| sizeFrom=inv_c.getInventorySize(side.front) | |
| robot.turnAround() | |
| sizeTiny =inv_c.getInventorySize(side.front) | |
| robot.turnAround() | |
| sizeDust =inv_c.getInventorySize(side.top) | |
| function dropTo(sideTo,sideSize) | |
| item = inv_c.getStackInInternalSlot() | |
| if item == nil then --перестраховка не более того | |
| print("WTF") | |
| return | |
| end | |
| for i = 1,sideSize do --пытаемся напонить стаки | |
| slot = inv_c.getStackInSlot(sideTo,i) | |
| if slot == nil then goto continue end | |
| if slot.label == item.label then | |
| toDrop = (slot.maxSize - slot.size) - item.size | |
| if toDrop >= 0 then | |
| inv_c.dropIntoSlot(sideTo,i) | |
| return | |
| else | |
| inv_c.dropIntoSlot(sideTo,i,-toDrop) | |
| end | |
| end | |
| ::continue:: | |
| end | |
| for i = 1,sideSize do --просто бросаем в пустой слот | |
| slot = inv_c.getStackInSlot(sideTo,i) | |
| if slot == nil then | |
| inv_c.dropIntoSlot(sideTo,i) | |
| return | |
| end | |
| end | |
| print("что то пошло не так " + item.label) | |
| for i = 1,5 do | |
| cmp.beep(500,5) | |
| end | |
| return dropTo(sideTo,sideSize) | |
| end | |
| while true do | |
| for i = 1, sizeFrom do | |
| item=inv_c.getStackInSlot(side.front,i) | |
| if item ~= nil and item.name == "ic2:dust" | |
| then | |
| if item.label:find("Tiny") ~= nil then | |
| if item.size <= 9 then | |
| goto continue | |
| end | |
| take = item.size - (item.size % 9) | |
| inv_c.suckFromSlot(side.front,i,take) | |
| robot.turnAround() | |
| dropTo(side.front,sizeTiny) | |
| robot.turnAround() | |
| else | |
| inv_c.suckFromSlot(side.front,i) | |
| dropTo(side.top,sizeDust) | |
| end | |
| end | |
| ::continue:: | |
| end | |
| os.sleep(10) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment