[2.0.11] Lua Key/Value Tables Don't Work For Some Users.
Posted: Sat Oct 26, 2024 1:05 pm
Hello, I'm the author of Unlimited Resources, recently I had a user by the name of Arcanical reach out about an error in the experimental branch. Upon investigating his issue we learned that the lua tables were not having their values assigned despite the function behaving as it should have. Furthermore, upon loading the experimental branch myself and having the same mod instance, which we confirmed by comparing all the code within the files, only Arcanical had the issue.
This was the code that was producing the issue:
My Output (Correct):
Arcanical's Output (Incorrect):
These outputs show that the split function was working, but Arcanical's table didn't include the boolean values it should've.
In the end, despite everything we tried, we couldn't figure out why his lua produced different results and sometimes crashed when using an attempted patch that worked fine for me.
This was the code that was producing the issue:
Code: Select all
function string:split(inSplitPattern)
local outResults = {}
if not self or self == "" then
return outResults
end
local str = ""
for i = 1, #self do
local char = self:sub(i, i)
if char == inSplitPattern then
outResults[str] = true
str = ""
else
str = str ..char
end
end
outResults[str] = true
return outResults
end
Code: Select all
@Unlimited-Resources-Oil-Refresh-Cargo-Ship-Compat/data-final-fixes.lua:42: InfiniteOreResources (7 items): {
calcite = true,
coal = true,
["copper-ore"] = true,
["iron-ore"] = true,
stone = true,
["tungsten-ore"] = true,
["uranium-ore"] = true
}
Code: Select all
@Unlimited-Resources-Oil-Refresh-Cargo-Ship-Compat/data-final-fixes.lua:42: InfiniteOreResources (7 items): {
"iron-ore",
"copper-ore",
"stone",
"coal",
"uranium-ore",
"tungsten-ore",
"calcite"
}
In the end, despite everything we tried, we couldn't figure out why his lua produced different results and sometimes crashed when using an attempted patch that worked fine for me.