Fix the damn fabricator recipes not
This commit is contained in:
@@ -547,14 +547,19 @@ Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptab
|
|||||||
-- For recipes that have multiple prefabs
|
-- For recipes that have multiple prefabs
|
||||||
-- But then again what if it has 3 items with 4 prefabs each..
|
-- But then again what if it has 3 items with 4 prefabs each..
|
||||||
-- Is that 4 iterations or 3*4 iterations?
|
-- Is that 4 iterations or 3*4 iterations?
|
||||||
|
-- We can not use #toFind because we can remove 0th item
|
||||||
|
-- Which means it's no longer contiguous
|
||||||
|
-- Which means #toFind returns 0
|
||||||
local toFind = recipe.requiredItems
|
local toFind = recipe.requiredItems
|
||||||
|
local remaining = #toFind
|
||||||
---@type Barotrauma.Item[]
|
---@type Barotrauma.Item[]
|
||||||
local toGet = {}
|
local toGet = {}
|
||||||
---@type fun(item: Barotrauma.Item): boolean, boolean
|
---@type fun(item: Barotrauma.Item): boolean, boolean
|
||||||
local filter = function(item)
|
local filter = function(item)
|
||||||
local found = false
|
local found = false
|
||||||
|
-- DumpTable(toFind)
|
||||||
-- toFind are all items we need to find
|
-- toFind are all items we need to find
|
||||||
for i, itemInfo in ipairs(toFind) do
|
for i, itemInfo in pairs(toFind) do
|
||||||
-- prefabs are all items that satisfy the requirements
|
-- prefabs are all items that satisfy the requirements
|
||||||
for _, prefab in ipairs(itemInfo.prefabs) do
|
for _, prefab in ipairs(itemInfo.prefabs) do
|
||||||
-- debugPrint(string.format("Checking %s against %s", item.Prefab.Identifier.Value, prefab))
|
-- debugPrint(string.format("Checking %s against %s", item.Prefab.Identifier.Value, prefab))
|
||||||
@@ -566,11 +571,16 @@ Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptab
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if itemInfo.amount <= 0 then toFind[i] = nil end
|
if itemInfo.amount <= 0 then
|
||||||
|
-- debugPrint(string.format("Removing %s from toFind", itemInfo.prefabs[1]))
|
||||||
|
toFind[i] = nil
|
||||||
|
remaining = remaining - 1
|
||||||
|
end
|
||||||
if found then break end
|
if found then break end
|
||||||
end
|
end
|
||||||
-- debugPrint(string.format("Found %s %s", item.Prefab.Identifier.Value, tostring(#toFind)))
|
-- DumpTable(toFind)
|
||||||
return found, #toFind == 0
|
-- debugPrint(string.format("Found %s %s", item.Prefab.Identifier.Value, tostring(remaining)))
|
||||||
|
return found, remaining == 0
|
||||||
end
|
end
|
||||||
-- DumpTable(toGet)
|
-- DumpTable(toGet)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user