Skip to content

Instantly share code, notes, and snippets.

@haylinmoore
Last active June 19, 2023 19:26
Show Gist options
  • Save haylinmoore/f6ce65ce4bee3f068a73147097fa82e0 to your computer and use it in GitHub Desktop.
Save haylinmoore/f6ce65ce4bee3f068a73147097fa82e0 to your computer and use it in GitHub Desktop.
local charged_certus_quartz = "ae2:charged_certus_quartz_crystal"
local regular_certus_quartz = "ae2:certus_quartz_crystal"
while true do
local charger = peripheral.find("ae2:charger")
if charger then
local item = charger.list()[0]
if item and item.name == charged_certus_quartz then
turtle.suck()
for slot = 1, 16 do
local slot_item = turtle.getItemDetail(slot)
if slot_item and slot_item.name == regular_certus_quartz then
turtle.select(slot)
turtle.drop()
break
end
end
end
else
print("No AE2 charger found.")
end
os.sleep(1)
end
local completion = require "cc.completion"
local inscriberDir = "front"
local chestDir = "top"
local inscriber = peripheral.wrap(inscriberDir)
local chest = peripheral.wrap(chestDir)
local items = {
["ae2:certus_quartz_dust"] = {nil, nil, "ae2:certus_quartz_crystal"},
["ae2:printed_silicon"] = {"ae2:silicon_press", nil, "ae2:silicon"},
["ae2:printed_calculation_processor"] = {"ae2:calculation_processor_press", nil, "ae2:certus_quartz_crystal"},
["ae2:printed_logic_processor"] = {"ae2:logic_processor_press", nil, "minecraft:gold_ingot"},
["ae2:printed_engineering_processor"] = {"ae2:engineering_processor_press", nil, "minecraft:diamond"},
["ae2:calculation_processor"] = {"ae2:printed_calculation_processor", "ae2:printed_silicon", "minecraft:redstone"},
["ae2:logic_processor"] = {"ae2:printed_logic_processor", "ae2:printed_silicon", "minecraft:redstone"},
["ae2:engineering_processor"] = {"ae2:printed_engineering_processor", "ae2:printed_silicon", "minecraft:redstone"},
}
local choices = {}
for key,_ in pairs(items) do
table.insert(choices, key)
end
print("Desired item: ")
local userSelection = read(nil, choices, function(text) return completion.choice(text, choices) end, "")
print("Selected " .. userSelection)
write("Desired count: ")
local goalStr = read(nil, nil, nil, "1")
local goal = tonumber(goalStr)
print("Making " .. goalStr .. " " .. userSelection)
local userItems = items[userSelection]
local itemLocations = {}
-- Find slots in chest and save to itemLocations, skip if nil
for i = 1, chest.size() do
local item = chest.getItemDetail(i)
if item then
print(item.name)
for j = 1,4 do
local name = userItems[j]
if name ~= nil and name == item.name then
itemLocations[j] = i
print("Found " .. name)
end
end
end
end
function pullAllItems()
-- Remove all items currently in the inscriber into the chest
for i = 1, inscriber.size() do
local item = inscriber.getItemDetail(i)
if item then
inscriber.pushItems(chestDir, i)
end
end
end
pullAllItems()
local count = 0
while (count < goal) do
-- Move one of each item from its slot in the chest into the inscriber
for i = 1, 4 do
local slot = itemLocations[i]
if slot ~= nil then
chest.pushItems(inscriberDir, slot, 1, i)
end
end
while (chest.pullItems(inscriberDir, 4) == 0) do
print("Waiting for inscribe to finish")
sleep(0.5)
end
count = count + 1
print("Finished item " .. count)
end
pullAllItems()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment