Skip to content

Commit

Permalink
Fixed bug in alloy furnaces.. No more messed counts of supplies when …
Browse files Browse the repository at this point in the history
…placed in wrong slots
  • Loading branch information
Pitriss committed Dec 22, 2013
1 parent 516788a commit c1faea4
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions technic/machines/alloy_furnaces_commons.lua
Expand Up @@ -3,34 +3,42 @@ technic.alloy_recipes = {}

-- Register recipe in a table
technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3)
technic.alloy_recipes[metal1..metal2] = { src1_count = count1, src2_count = count2, dst_name = result, dst_count = count3 }
if unified_inventory then
unified_inventory.register_craft(
{
type = "alloy",
output = result.." "..count3,
items = {metal1.." "..count1,metal2.." "..count2},
width = 2,
})
end
end
technic.alloy_recipes[metal1..metal2] = { src1_count = count1, src2_count = count2, dst_name = result, dst_count = count3 }
if unified_inventory then
unified_inventory.register_craft(
{
type = "alloy",
output = result.." "..count3,
items = {metal1.." "..count1,metal2.." "..count2},
width = 2,
})
end
end

-- Retrieve a recipe given the input metals.
-- Input parameters are a table from a StackItem
technic.get_alloy_recipe = function(metal1, metal2)
-- Check for both combinations of metals and for the right amount in both
if technic.alloy_recipes[metal1.name..metal2.name]
and metal1.count >= technic.alloy_recipes[metal1.name..metal2.name].src1_count
and metal2.count >= technic.alloy_recipes[metal1.name..metal2.name].src2_count then
return technic.alloy_recipes[metal1.name..metal2.name]
elseif technic.alloy_recipes[metal2.name..metal1.name]
and metal2.count >= technic.alloy_recipes[metal2.name..metal1.name].src1_count
and metal1.count >= technic.alloy_recipes[metal2.name..metal1.name].src2_count then
return technic.alloy_recipes[metal2.name..metal1.name]
else
return nil
end
end
-- Check for both combinations of metals and for the right amount in both
if technic.alloy_recipes[metal1.name..metal2.name]
and metal1.count >= technic.alloy_recipes[metal1.name..metal2.name].src1_count
and metal2.count >= technic.alloy_recipes[metal1.name..metal2.name].src2_count then
return technic.alloy_recipes[metal1.name..metal2.name]
elseif technic.alloy_recipes[metal2.name..metal1.name]
and metal2.count >= technic.alloy_recipes[metal2.name..metal1.name].src1_count
and metal1.count >= technic.alloy_recipes[metal2.name..metal1.name].src2_count then
local tmp = {}
for key, value in pairs( technic.alloy_recipes[metal2.name..metal1.name] ) do
tmp[key] = value
end
local tmp_value = tmp.src1_count
tmp.src1_count = tmp.src2_count
tmp.src2_count = tmp_value
return tmp
else
return nil
end
end


technic.register_alloy_recipe("technic:copper_dust", 3, "technic:tin_dust", 1, "technic:bronze_dust", 4)
technic.register_alloy_recipe("moreores:copper_ingot",3, "moreores:tin_ingot", 1, "moreores:bronze_ingot", 4)
Expand Down

0 comments on commit c1faea4

Please sign in to comment.