forked from VoxeLibre/VoxeLibre
Shift to table lookup for brewing combinations. Fix issue with brewing only if all slots filled.
This commit is contained in:
parent
861aedbfa3
commit
bcdb37800d
|
@ -73,9 +73,9 @@ end
|
||||||
local function brewable(inv)
|
local function brewable(inv)
|
||||||
|
|
||||||
local ingredient = inv:get_stack("input",1):get_name()
|
local ingredient = inv:get_stack("input",1):get_name()
|
||||||
local stands = {"","",""}
|
local stands = {}
|
||||||
local stand_size = inv:get_size("stand")
|
local stand_size = inv:get_size("stand")
|
||||||
local was_alchemy = true
|
local was_alchemy = {false,false,false}
|
||||||
|
|
||||||
for i=1,stand_size do
|
for i=1,stand_size do
|
||||||
|
|
||||||
|
@ -84,14 +84,16 @@ local function brewable(inv)
|
||||||
local alchemy = mcl_potions.get_alchemy(ingredient, bottle)
|
local alchemy = mcl_potions.get_alchemy(ingredient, bottle)
|
||||||
if alchemy then
|
if alchemy then
|
||||||
stands[i] = alchemy
|
stands[i] = alchemy
|
||||||
|
was_alchemy[i] = true
|
||||||
else
|
else
|
||||||
stands[i] = bottle
|
stands[i] = bottle
|
||||||
was_alchemy = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
-- if any stand holds a new potion, return the list of new potions
|
-- if any stand holds a new potion, return the list of new potions
|
||||||
if was_alchemy then return stands end
|
for i=1,table.getn(was_alchemy) do
|
||||||
|
if was_alchemy[i] then return stands end
|
||||||
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -205,12 +207,6 @@ local function brewing_stand_timer(pos, elapsed)
|
||||||
fuel_totaltime = fuel.time
|
fuel_totaltime = fuel.time
|
||||||
end
|
end
|
||||||
|
|
||||||
-- for i=1, inv:get_size("stand") do
|
|
||||||
-- if stand_list[i]:is_empty() then
|
|
||||||
-- stand_timer = 0
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
--update formspec
|
--update formspec
|
||||||
local formspec = brewing_formspec
|
local formspec = brewing_formspec
|
||||||
|
|
||||||
|
|
|
@ -359,26 +359,33 @@ minetest.register_craftitem("mcl_potions:swiftness", {
|
||||||
|
|
||||||
mcl_potions = {}
|
mcl_potions = {}
|
||||||
|
|
||||||
|
function key_in_table(table,key)
|
||||||
|
return table[key] ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local water_table = {
|
||||||
|
["mcl_nether:nether_wart_item"] = "mcl_potions:potion_awkward",
|
||||||
|
["mcl_potions:fermented_spider_eye"] = "mcl_potions:weakness",
|
||||||
|
}
|
||||||
|
local awkward_table = {
|
||||||
|
["mcl_potions:speckled_melon"] = "mcl_potions:healing",
|
||||||
|
["mcl_farming:carrot_item_gold"] = "mcl_potions:night_vision",
|
||||||
|
["mcl_core:sugar"] = "mcl_potions:swiftness",
|
||||||
|
}
|
||||||
|
local output_table = {
|
||||||
|
["mcl_potions:potion_river_water"] = water_table,
|
||||||
|
["mcl_potions:potion_water"] = water_table,
|
||||||
|
["mcl_potions:potion_awkward"] = awkward_table,
|
||||||
|
}
|
||||||
|
|
||||||
-- Compare two ingredients for compatable alchemy
|
-- Compare two ingredients for compatable alchemy
|
||||||
function mcl_potions.get_alchemy(ingr, pot)
|
function mcl_potions.get_alchemy(ingr, pot)
|
||||||
|
|
||||||
if pot == "mcl_potions:potion_river_water" or pot == "mcl_potions:potion_water" then
|
if output_table[pot] ~= nil then
|
||||||
if ingr == "mcl_nether:nether_wart_item" then
|
local brew_table = output_table[pot]
|
||||||
return "mcl_potions:potion_awkward"
|
if brew_table[ingr] ~= nil then
|
||||||
elseif ingr == "mcl_potions:fermented_spider_eye" then
|
return brew_table[ingr]
|
||||||
return "mcl_potions:weakness"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif pot == "mcl_potions:potion_awkward" then
|
|
||||||
if ingr == "mcl_potions:speckled_melon" then
|
|
||||||
return "mcl_potions:healing"
|
|
||||||
elseif ingr == "mcl_farming:carrot_item_gold" then
|
|
||||||
return "mcl_potions:night_vision"
|
|
||||||
elseif ingr == "mcl_core:sugar" then
|
|
||||||
return "mcl_potions:swiftness"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
|
||||||
return false
|
return false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue