## count vs count_forumla

Place to get help with not working mods / modding interface.
Bizobinator
Fast Inserter
Posts: 190
Joined: Fri May 06, 2016 10:35 pm
Contact:

### count vs count_forumla

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?

Choumiko
Smart Inserter
Posts: 1290
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

### Re: count vs count_forumla

Hiladdar
Long Handed Inserter
Posts: 82
Joined: Mon May 14, 2018 6:47 pm
Contact:

### Re: count vs count_forumla

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.

Hiladdar

Bizobinator
Fast Inserter
Posts: 190
Joined: Fri May 06, 2016 10:35 pm
Contact:

### Re: count vs count_forumla

Excellent! Thanks y'all! ^_^

Bizobinator
Fast Inserter
Posts: 190
Joined: Fri May 06, 2016 10:35 pm
Contact:

### Re: count vs count_forumla

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 70 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``````

Choumiko
Smart Inserter
Posts: 1290
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

### Re: count vs count_forumla

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

### Who is online

Users browsing this forum: No registered users