SHOW:
|
|
- or go back to the newest paste.
| 1 | local monitor = peripheral.wrap("monitor_0")
| |
| 2 | ||
| 3 | if monitor then | |
| 4 | monitor.setTextScale(0.5) | |
| 5 | monitor.setBackgroundColor(colors.black) | |
| 6 | monitor.setTextColor(colors.white) | |
| 7 | monitor.clear() | |
| 8 | monitor.setCursorPos(1, 1) | |
| 9 | ||
| 10 | term.redirect(monitor) | |
| 11 | end | |
| 12 | ||
| 13 | local schematicChest = "minecraft:chest_0" | |
| 14 | ||
| 15 | local handleChest = "minecraft:chest_1" | |
| 16 | local partChest = "minecraft:chest_1" -- backup chest for parts I might have missed | |
| 17 | ||
| 18 | local axeHeadChest = "minecraft:chest_2" | |
| 19 | ||
| 20 | local swordBladeChest = "minecraft:chest_3" | |
| 21 | ||
| 22 | local shovelHeadChest = "minecraft:chest_5" | |
| 23 | ||
| 24 | local pickaxeHeadChest = "minecraft:chest_6" | |
| 25 | ||
| 26 | local materialChest = "minecraft:chest_7" | |
| 27 | ||
| 28 | local hoeHeadChest = "minecraft:chest_8" | |
| 29 | ||
| 30 | local allChests = { -- Used for debugging, not needed for the actual program
| |
| 31 | schematicChest, | |
| 32 | handleChest, | |
| 33 | partChest, | |
| 34 | axeHeadChest, | |
| 35 | swordBladeChest, | |
| 36 | shovelHeadChest, | |
| 37 | pickaxeHeadChest, | |
| 38 | materialChest, | |
| 39 | hoeHeadChest | |
| 40 | } | |
| 41 | ||
| 42 | local bufferChest = "minecraft:chest_4" -- chest to dump all items into, this is what we'll be pulling from. | |
| 43 | ||
| 44 | local tags = {
| |
| 45 | "forgero:schematic", | |
| 46 | "forgero:gem", | |
| 47 | "forgero:trinket", | |
| 48 | "forgero:binding", | |
| 49 | "forgero:handle", | |
| 50 | "forgero:hoe_head", | |
| 51 | "forgero:pickaxe_head", | |
| 52 | "forgero:sword_blade", | |
| 53 | "forgero:axe_head", | |
| 54 | "forgero:shovel_head", | |
| 55 | "forgero:part", | |
| 56 | "forgero:material" | |
| 57 | } | |
| 58 | ||
| 59 | local chests = {
| |
| 60 | ["forgero:schematic"] = schematicChest, | |
| 61 | ["forgero:gem"] = handleChest, | |
| 62 | ["forgero:trinket"] = handleChest, | |
| 63 | ["forgero:binding"] = handleChest, | |
| 64 | ["forgero:handle"] = handleChest, | |
| 65 | ["forgero:hoe_head"] = hoeHeadChest, | |
| 66 | ["forgero:pickaxe_head"] = pickaxeHeadChest, | |
| 67 | ["forgero:sword_blade"] = swordBladeChest, | |
| 68 | ["forgero:axe_head"] = axeHeadChest, | |
| 69 | ["forgero:shovel_head"] = shovelHeadChest, | |
| 70 | ["forgero:part"] = partChest, | |
| 71 | ["forgero:material"] = materialChest | |
| 72 | } | |
| 73 | ||
| 74 | while true do | |
| 75 | local items = luna.getItems({
| |
| 76 | ["inventories"] = {bufferChest}
| |
| 77 | }) | |
| 78 | ||
| 79 | for k, item in pairs(items) do | |
| 80 | for _, tag in ipairs(tags) do | |
| 81 | ||
| 82 | if luna.hasTags(item, tag) and item.name ~= "minecraft:totem_of_undying" then | |
| 83 | -- luna.log("Found " .. tag .. ": " .. item.name)
| |
| 84 | local p = peripheral.wrap(chests[tag]) | |
| 85 | ||
| 86 | for _, slot in pairs(item.slots) do | |
| 87 | -- slot is a string, so we need to convert it to a number | |
| 88 | local numberOfItemsTransferred = p.pullItems(item.where, tonumber(slot)) | |
| 89 | ||
| 90 | if numberOfItemsTransferred <= 0 then | |
| 91 | luna.error("No space for " .. item.name .. " in " .. chests[tag])
| |
| 92 | else | |
| 93 | luna.log(item.name .. " >> " .. chests[tag]) | |
| 94 | end | |
| 95 | end | |
| 96 | ||
| 97 | break | |
| 98 | end | |
| 99 | end | |
| 100 | end | |
| 101 | ||
| 102 | sleep() | |
| 103 | end |