count vs count_forumla
-
- Fast Inserter
- Posts: 193
- 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?
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
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
-
- Fast Inserter
- Posts: 193
- Joined: Fri May 06, 2016 10:35 pm
- Contact:
Re: count vs count_forumla
Excellent! Thanks y'all! ^_^
-
- Fast Inserter
- Posts: 193
- 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...
And this is my code...
This is the error...
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
you put the techMult variable in the string, depending on how you want it to apply it should be
or something along those lines
Code: Select all
unitTechCopy.count_formula = "2^(L-6)*" .. 1000*techMult