Factorio: Detect if more than one AP factorio mod is loaded. (#964)

This commit is contained in:
CaitSith2 2022-08-26 01:31:30 -07:00 committed by GitHub
parent a78863fde1
commit a175aa93e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,21 @@
-- Find out if more than one AP mod is loaded, and if so, error out.
function mod_is_AP(str)
-- lua string.match is way more restrictive than regex. Regex would be "^AP-W?\d{20}-P[1-9]\d*-.+$"
local result = string.match(str, "^AP%-W?%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%-P[1-9]%d-%-.+$")
if result ~= nil then
log("Archipelago Mod: " .. result .. " is loaded.")
end
return result ~= nil
end
local ap_mod_count = 0
for name, _ in pairs(mods) do
if mod_is_AP(name) then
ap_mod_count = ap_mod_count + 1
if ap_mod_count > 1 then
error("More than one Archipelago Factorio mod is loaded.")
end
end
end
data:extend({
{
type = "bool-setting",