Compare commits

..

No commits in common. 'd30888cb69b67ddacbed8b169d9e19ab1c7898e4' and '06aee93cc7ec81500e64b1ad2cd04a8831dd48cb' have entirely different histories.

@ -326,9 +326,8 @@ end
---accepts a recipe table ---accepts a recipe table
---@param search string search for an craftable item ---@param search string search for an craftable item
---@param amount number how many items to craft
---@return boolean ---@return boolean
local function craft_item(search, amount) local function craft_item(search)
search = string.lower(search) -- convert to unified lowercase search = string.lower(search) -- convert to unified lowercase
local matches = {} local matches = {}
@ -375,72 +374,67 @@ local function craft_item(search, amount)
local recipe = recipes[selected] local recipe = recipes[selected]
print('Trying to craft ' .. amount .. 'x ' .. recipe.result) print('Trying to craft ' .. recipe.result)
local repeating = false local available_items = read_chest_contents()
if not available_items then
local count = math.ceil(amount / recipe.count) print('Not facing a chest')
return false
for _ = 1, count do end
local available_items = read_chest_contents()
if not available_items then
print('Not facing a chest')
return false
end
local required_items, crafting_order = craft_recipe_recursion(recipe, clone(available_items), {}) local required_items, crafting_order = craft_recipe_recursion(recipe, clone(available_items), {})
print('\nRequires these items:') print('\nRequires these items:')
local failed = false local failed = false
for required_item, required_count in pairs(required_items) do for required_item, required_count in pairs(required_items) do
local available = available_items[required_item] local available = available_items[required_item]
if not available then if not available then
available = 0 available = 0
end
if available < required_count then
print(available .. "/" .. required_count .. "\t" .. required_item .. "\t- Missing " .. required_count - available)
failed = true
else
print(available .. "/" .. required_count .. "\t" .. required_item)
end
end end
if failed then if available < required_count then
return false print(available .. "/" .. required_count .. "\t" .. required_item .. "\t- Missing " .. required_count - available)
failed = true
else
print(available .. "/" .. required_count .. "\t" .. required_item)
end end
end
if failed then
return false
end
if not repeating then if not confirm() then
if not confirm() then print('Operation cancelled')
print('Operation cancelled') return false
return false end
end
end
-- proceed to crafting the things -- print('\nCrafting in order:')
local steps = #crafting_order -- for i, rec in ipairs(crafting_order) do
for i, rec in ipairs(crafting_order) do -- print(i, rec.result)
print('Step ' .. i .. '/' .. steps .. ' - ' .. rec.result) -- end
if not craft_single_recipe(rec, 1) then
print('Unexpected error') -- if not confirm() then
return false -- print('Operation cancelled')
end -- return false
-- end
-- proceed to crafting the things
for i, rec in ipairs(crafting_order) do
print('Step #' .. i .. ' - ' .. rec.result)
if not craft_single_recipe(rec, 1) then
print('Unexpected error')
return false
end end
repeating = true
end end
return true return true
end end
local target, amount = ... local target = ...
if not target then if not target then
print("Usage: craft <item> [count]") print("Usage: craft <item>")
return return
end end
if not amount then craft_item(target)
amount = 1
end
craft_item(target, amount)

@ -844,54 +844,6 @@ return {
nil, 'opencomputers:material;5', 'minecraft:obsidian;0', nil, 'opencomputers:material;5', 'minecraft:obsidian;0',
} }
}, },
-- Data card (Tier 1)
['opencomputers:card;10'] = {
result = 'opencomputers:card;10;data card 1',
count = 1,
requires = {
['minecraft:iron_nugget;0'] = 1,
['opencomputers:material;10'] = 1, -- ALU
['opencomputers:material;8'] = 1, -- Microchip (Tier 2)
['opencomputers:material;5'] = 1, -- Card Base
},
shape = {
nil, nil, nil,
'minecraft:iron_nugget;0', 'opencomputers:material;10', 'opencomputers:material;8',
nil, 'opencomputers:material;5', nil,
}
},
-- Data card (Tier 2)
['opencomputers:card;11'] = {
result = 'opencomputers:card;11;data card 2',
count = 1,
requires = {
['minecraft:gold_nugget;0'] = 1,
['opencomputers:component;0'] = 1, -- CPU 1
['opencomputers:material;9'] = 1, -- Microchip (Tier 3)
['opencomputers:material;5'] = 1, -- Card Base
},
shape = {
nil, nil, nil,
'minecraft:gold_nugget;0', 'opencomputers:component;0', 'opencomputers:material;9',
nil, 'opencomputers:material;5', nil,
}
},
-- Data card (Tier 3)
['opencomputers:card;12'] = {
result = 'opencomputers:card;12;data card 3',
count = 1,
requires = {
['opencomputers:material;29'] = 1, -- Diamond Chip
['opencomputers:component;1'] = 1, -- CPU 2
['opencomputers:component;10'] = 1, -- RAM 3
['opencomputers:material;5'] = 1, -- Card Base
},
shape = {
nil, nil, nil,
'opencomputers:material;29', 'opencomputers:component;1', 'opencomputers:component;10',
nil, 'opencomputers:material;5', nil,
}
},
-- EEPROM -- EEPROM
['opencomputers:storage;0'] = { ['opencomputers:storage;0'] = {

Loading…
Cancel
Save