require "/HLib/Scripts/HelperScripts.lua"
function GetLiquidCombinations()
local Liquids = {};
local function LiquidInteraction (ingredient1,ingredient2,result)
local self = {};
self.Ingredient1 = ingredient1;
self.Ingredient2 = ingredient2;
self.Result = result;
return self;
end
for i=1,256 do
local liquid = root.liquidConfig(i);
if liquid then
Liquids[i] = liquid;
end
end
local ItemLiquids = {}
local nameToItem = function (itemname)
return Item({name = itemname,count = 1});
end
local nameToDisplayName = function (id,itemname)
if id == 8 then
return "Core Lava";
else
return nameToItem(itemname).DisplayName;
end
end
local materialToDisplayName = function (material)
return nameToItem(root.materialConfig(material).config.itemDrop).DisplayName;
end
for id,liquid in pairs(Liquids) do
local item = nameToDisplayName(id,liquid.config.itemDrop);
ItemLiquids[id] = {Name = item; Interactions = liquid.config.interactions};
end
local LiquidInteractions = {};
for id,liquid in pairs(ItemLiquids) do
if liquid.Interactions then
for i=1,#liquid.Interactions do
local mix = liquid.Interactions[i];
if mix.materialResult then
LiquidInteractions[#LiquidInteractions + 1] = LiquidInteraction(liquid.Name,ItemLiquids[mix.liquid].Name,materialToDisplayName(mix.materialResult));
else
if mix.liquidResult ~= 0 then
LiquidInteractions[#LiquidInteractions + 1] = LiquidInteraction(liquid.Name,ItemLiquids[mix.liquid].Name,ItemLiquids[mix.liquidResult].Name);
end
end
end
end
end
local interactions = #LiquidInteractions;
for i=1,interactions do
LiquidInteractions[#LiquidInteractions + 1] = LiquidInteraction(LiquidInteractions[i].Ingredient2,LiquidInteractions[i].Ingredient1,LiquidInteractions[i].Result);
end
local output = "";
for i=1,#LiquidInteractions do
output = output .. LiquidInteractions[i].Ingredient1 .. ";"..LiquidInteractions[i].Ingredient2.. ";"..LiquidInteractions[i].Result.."\n";
end
LogDebug(output);
output = "";
local results = {};
local function res_contains(int)
for i=1,#results do
if results[i].Result == int.Result and ((results[i].Ingredient1 == int.Ingredient1 and results[i].Ingredient2 == int.Ingredient2) or ((results[i].Ingredient1 == int.Ingredient2 and results[i].Ingredient2 == int.Ingredient1))) then
return true;
end
end
return false;
end
for i=1,#LiquidInteractions do
if not res_contains(LiquidInteractions[i]) then
results[#results + 1] = LiquidInteractions[i];
output = output .. LiquidInteractions[i].Ingredient1 .. ";"..LiquidInteractions[i].Ingredient2.. ";"..LiquidInteractions[i].Result.."\n";
end
end
LogDebug(output);
end
Comments
0 B
|👍
/👎