Created
January 19, 2022 13:01
-
-
Save djmattyg007/25e27637e5d568fe3fd6c6ca1caccc9a 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
local function outputSides(box, north, east, south, west) | |
box.setOutput("top", false) | |
box.setOutput("bottom", false) | |
box.setOutput("north", north) | |
box.setOutput("east", east) | |
box.setOutput("south", south) | |
box.setOutput("west", west) | |
end | |
return { outputSides = outputSides } |
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
local function hasTag(item, tag) | |
local tags = item["tags"] | |
if not tags then | |
return false | |
end | |
if tags[tag] then | |
return true | |
else | |
return false | |
end | |
end | |
return { hasTag = hasTag } |
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
local function eq(val1, val2) | |
return val1 == val2 | |
end | |
local function neq(val1, val2) | |
return val1 ~= val2 | |
end | |
return { eq = eq, neq = neq } |
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
lualib = require("mylualib") | |
operator = require("operatorlib") | |
rsilib = require("ccrsilib") | |
minelib = require("minelib") | |
inputChestName = "minecraft:barrel_0" | |
inputChest = peripheral.wrap(inputChestName) | |
hopperName = "minecraft:hopper_0" | |
hopper = peripheral.wrap(hopperName) | |
outputChestName = "abnormals_core:chest_8" | |
outputChest = peripheral.wrap(outputChestName) | |
interfaceName = "refinedstorage:interface_1" | |
interface = peripheral.wrap(interfaceName) | |
rsiName = "redstoneIntegrator_3" | |
rsi = peripheral.wrap(rsiName) | |
function findItem(inv, itemName, op) | |
for slot, item in pairs(inv.list()) do | |
if op(item.name, itemName) then | |
return slot | |
end | |
end | |
return -1 | |
end | |
function findByTag(inv, tag) | |
for slot, item in pairs(inv.list()) do | |
itemDetail = inv.getItemDetail(slot) | |
if minelib.hasTag(itemDetail, tag) then | |
return slot | |
end | |
end | |
return -1 | |
end | |
function processInput(inv) | |
waterBucketSlot = findItem(inv, "minecraft:water_bucket", operator.eq) | |
if waterBucketSlot > -1 then | |
print("pushing water bucket") | |
inv.pushItems(hopperName, waterBucketSlot) | |
return | |
end | |
nonSeedSlot = findItem(inv, "minecraft:wheat_seeds", operator.neq) | |
if nonSeedSlot > -1 then | |
print("pushing non-seed") | |
inv.pushItems(hopperName, nonSeedSlot) | |
return | |
end | |
seedSlot = findItem(inv, "minecraft:wheat_seeds", operator.eq) | |
if seedSlot > -1 then | |
print("pushing wheat seed") | |
inv.pushItems(hopperName, seedSlot) | |
return | |
end | |
end | |
function processOutput(inv) | |
for slot, item in pairs(inv.list()) do | |
if item.name == "minecraft:wheat_seeds" then | |
inv.pushItems(hopperName, slot) | |
return | |
end | |
itemDetail = inv.getItemDetail(slot) | |
if minelib.hasTag(itemDetail, "botania:petals") then | |
inv.pushItems(hopperName, slot) | |
return | |
end | |
isFlower = minelib.hasTag(itemDetail, "botania:special_flowers") | |
if isFlower then | |
print("starting redstone pulse") | |
rsilib.outputSides(rsi, false, false, true, false) | |
end | |
print(("pushing to output: %s"):format(item.name)) | |
inv.pushItems(interfaceName, slot) | |
if isFlower then | |
print("ending redstone pulse") | |
rsilib.outputSides(rsi, false, false, false, false) | |
end | |
return | |
end | |
end | |
while true do | |
processInput(inputChest) | |
processOutput(outputChest) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment