Page 1 of 1

count vs count_forumla

Posted: Sat May 18, 2019 1:43 am
I've been working on a mod that deals with adjusting research cost, and I've been looking at a few other mods to see how they did it. I came across both "count" and "count_formula"... Is there a documentation page that explains the difference?

Re: count vs count_forumla

Posted: Sat May 18, 2019 3:49 am

Re: count vs count_forumla

Posted: Sat May 18, 2019 4:29 pm
Count usually refers to a single number.

Count_formula refers tells the code to perform a numeric operation to determine the value.

In research of technology it is as follows:

count = 200,
or
count_formula = "2000*(L-7)-1000",

In the first example, the technology cost to advance that technology is 200, in the second case, Factorio takes the current level of the technology in question, and applies the formula.

Re: count vs count_forumla

Posted: Sun May 19, 2019 2:44 pm
Excellent! Thanks y'all! ^_^

Re: count vs count_forumla

Posted: Sun May 19, 2019 4:10 pm
Hmm.... Is there a way to include another variable in the equation? I keep getting a nastigram that it's using a variable other than "L" or "l".

This is the error... count formula error.PNG (23.03 KiB) Viewed 49 times
And this is my code...

Code: Select all

``````if (settings.startup["all-sci-cost-mult"].value ~= nil) then

bizobTechMult = settings.startup["all-sci-cost-mult"].value;

for index,tech in pairs(data.raw.technology) do
local unitTechCopy = table.deepcopy( tech.unit )
local techMult = bizobTechMult

if (unitTechCopy.count ~= nil) then
unitTechCopy.count = math.max(math.floor(unitTechCopy.count * bizobTechMult));
end

if (unitTechCopy.count_formula ~= nil) then

unitTechCopy.count_formula = "2^(L-6)*1000*techMult"

end

tech.unit = unitTechCopy

end
end``````

Re: count vs count_forumla

Posted: Sun May 19, 2019 4:26 pm
you put the techMult variable in the string, depending on how you want it to apply it should be

Code: Select all

``unitTechCopy.count_formula = "2^(L-6)*" .. 1000*techMult``
or something along those lines