Editing effects of every module
Posted: Fri Jul 26, 2024 11:05 am
As the title says I'm trying to edit the positive and negative effects of every module in the game, including ones added by other mods. I have two versions of the mod, one of them works fine and the other doesn't.
This version only affects the vanilla modules, I've tested it and it works fine:
However this doesn't account for modules added by other mods. So I made this version:
This version doesn't work, the mod will successfully load but none of the modules change their effects, not even the vanilla ones.
Any advice on how to do this?
This version only affects the vanilla modules, I've tested it and it works fine:
Code: Select all
--data.lua
m = settings.startup["module-good-multiplier"].value
n = settings.startup["module-bad-multiplier"].value
data.raw["module"]["effectivity-module"].effect = {
consumption = {bonus = -0.3*m}
}
data.raw["module"]["effectivity-module-2"].effect = {
consumption = {bonus = -0.4*m}
}
data.raw["module"]["effectivity-module-3"].effect = {
consumption = {bonus = -0.5*m}
}
data.raw["module"]["productivity-module"].effect = {
consumption = {bonus = 0.4*n},
pollution = {bonus = 0.05*n},
productivity = {bonus = 0.04*m},
speed = {bonus = -0.15*n}
}
data.raw["module"]["productivity-module-2"].effect = {
consumption = {bonus = 0.6*n},
pollution = {bonus = 0.075*n},
productivity = {bonus = 0.06*m},
speed = {bonus = -0.15*n}
}
data.raw["module"]["productivity-module-3"].effect = {
consumption = {bonus = 0.8*n},
pollution = {bonus = 0.1*n},
productivity = {bonus = 0.1*m},
speed = {bonus = -0.15*n}
}
data.raw["module"]["speed-module"].effect = {
consumption = {bonus = 0.5*n},
speed = {bonus = 0.2*m}
}
data.raw["module"]["speed-module-2"].effect = {
consumption = {bonus = 0.6*n},
speed = {bonus = 0.3*m}
}
data.raw["module"]["speed-module-3"].effect = {
consumption = {bonus = 0.7*n},
speed = {bonus = 0.5*m}
}
Code: Select all
--data.lua
m = settings.startup["module-good-multiplier"].value
n = settings.startup["module-bad-multiplier"].value
for k, x in ipairs(data.raw.module) do
if (x.effect.consumption.bonus > 0) then
x.effect.consumption.bonus = x.effect.consumption.bonus * n
elseif (x.effect.consumption.bonus < 0) then
x.effect.consumption.bonus = x.effect.consumption.bonus * m
end
if (x.effect.pollution.bonus > 0) then
x.effect.pollution.bonus = x.effect.pollution.bonus * n
elseif (x.effect.pollution.bonus < 0) then
x.effect.pollution.bonus = x.effect.pollution.bonus * m
end
if (x.effect.speed.bonus > 0) then
x.effect.speed.bonus = x.effect.speed.bonus * m
elseif (x.effect.speed.bonus < 0) then
x.effect.speed.bonus = x.effect.speed.bonus * n
end
if (x.effect.productivity.bonus > 0) then
x.effect.productivity.bonus = x.effect.productivity.bonus * m
elseif (x.effect.productivity.bonus < 0) then
x.effect.productivity.bonus = x.effect.productivity.bonus * n
end
end
Any advice on how to do this?