Skip to content

Instantly share code, notes, and snippets.

@Snownee
Last active November 18, 2022 19:37
Show Gist options
  • Save Snownee/40bdd4e886f1c0107ee9685b923fdf60 to your computer and use it in GitHub Desktop.
Save Snownee/40bdd4e886f1c0107ee9685b923fdf60 to your computer and use it in GitHub Desktop.
Enigmatica 6 Expert 电脑全自动装配线打包脚本
-- 需要配合RS和Entangled使用
recipes = {}
net = peripheral.find('rsBridge')
press = peripheral.wrap('top')
depot = peripheral.wrap('front')
deployer = peripheral.wrap('bottom')
function main()
addRecipe('dr', 'pneumaticcraft:plastic', {
'emendatusenigmatica:aluminum_plate',
'powah:dielectric_paste',
'emendatusenigmatica:signalum_plate',
'p'
}, 4) --基础电容
addRecipe('jzcl', 'mekanism:cardboard_box', {
'immersiveengineering:treated_wood_horizontal',
'immersiveengineering:treated_wood_horizontal',
'immersiveengineering:treated_wood_horizontal',
'immersiveengineering:treated_wood_horizontal',
'create:copper_shingles',
'quark:framed_glass'
}, 500) --建筑材料
addRecipe('jcjc', 'mekanism:cardboard_box', {
'immersiveengineering:concrete',
'immersiveengineering:concrete',
'immersiveengineering:concrete',
'immersiveengineering:steel_scaffolding_standard',
'engineersdecor:clinker_brick_block',
'engineersdecor:clinker_brick_block'
}, 500) --基础建材
addRecipe('lhcl', 'mekanism:cardboard_box', {
'quark:turf',
'quark:turf',
'quark:turf',
'quark:turf',
'minecraft:dandelion',
'minecraft:oak_leaves'
}, 250) --绿化材料
addRecipe('xsc', 'mekanism:cardboard_box', {
'create:builders_tea',
'create:builders_tea',
'simplefarming:vegetable_curry',
'simpledelights:mango_wings',
'simpledelights:plum_pudding',
'minecraft:enchanted_golden_apple'
}, 60) --学生餐
addRecipe('jmgj', 'emendatusenigmatica:gold_plate', {
'create:cogwheel',
'create:large_cogwheel',
'minecraft:iron_nugget'
}, 5) --精密构件
addRecipe('dnbg', 'mekanism:cardboard_box', {
'rftoolsbase:tablet',
'rftoolsbase:tablet',
'rftoolsbase:tablet',
'rftoolsbase:tablet'
}, 5) --电脑包裹
addRecipe('jlz', 'minecraft:paper', {
'kubejs:coke_brick',
'kubejs:coke_brick',
'kubejs:coke_brick',
'buildinggadgets:construction_paste'
}, 4) --焦炉砖
addRecipe('yz', 'kubejs:smoldering_lapis_lazuli_compound', {
'kubejs:blast_brick',
'kubejs:blast_brick',
'kubejs:blast_brick',
'environmental:mud_brick',
'buildinggadgets:construction_paste'
}, 4) --窑砖
while true do
print('Enter a recipe:')
local recipeId, times = parseInput()
local skipBase = false
if times == -1 then
skipBase = true
times = 1
end
local recipe = recipes[recipeId]
if recipe == nil then
print(string.format('Unknown recipe: %s', recipeId))
else
for i=1, times do
process(recipe, skipBase)
print('Done')
end
end
end
end
function parseInput()
local input = read()
local ws = string.find(input, ' ')
if ws == nil then
return input, 1
else
return string.sub(input, 1, ws - 1), tonumber(string.sub(input, ws + 1))
end
end
function addRecipe(name, base, steps, repeats)
recipes[name] = {
base = base,
steps = steps,
repeats = repeats
}
end
lastStep = nil
nbtHash = nil
function process(recipe, skipBase)
if not(skipBase) then
want(recipe.base, 'front') --第一步必定为deployer而不是press
end
for r=1, recipe.repeats do
for s, curStep in ipairs(recipe.steps) do
if curStep == 'p' then --press
if lastStep ~= 'p' then
press.pullItems('front', 1)
end
else
if lastStep == 'p' then
depot.pullItems('top', 1)
end
want(curStep, 'bottom')
end
lastStep = curStep
waitForComplete()
end
print(string.format('%s/%s', r, recipe.repeats))
end
if lastStep == 'p' then
net.importItemFromPeripheral(getCurItem(), 'top')
else
net.importItemFromPeripheral(getCurItem(), 'front')
end
end
function getCurItem()
if lastStep == 'p' then
return press.getItemDetail(1)
else
return depot.getItemDetail(1)
end
end
function waitForComplete()
while true do
local item = getCurItem()
if item.nbt ~= nbtHash then
nbtHash = item.nbt
break
end
sleep(0.1)
end
end
function want(item, toSide)
local re = 0
local inform = true
item = { name = item }
while true do
re = net.exportItemToPeripheral(item, toSide)
if re > 0 then
if not(inform) then
print('OK')
end
break
end
if net.isItemCraftable(item) then
if not(net.isItemCrafting(item.name)) then
net.craftItem(item)
end
else
if inform then
inform = false
io.write(string.format('Waiting for: %s ', item.name))
end
end
sleep(1)
end
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment