Page 1 of 1
Weird code in Electric Mining Drill?
Posted: Tue Jul 25, 2017 9:59 am
by Xerus
When I wanted to make my own drill, i looked at the prototype for the electric mining drill and found this:
Code: Select all
energy_source =
{
type = "electric",
-- will produce this much * energy pollution units per tick
emissions = 0.15 / 1.5,
usage_priority = "secondary-input"
}
why write 0.15/1.5 and not simply 0.1? Is there any reason?
Re: Weird code in Electric Mining Drill?
Posted: Tue Jul 25, 2017 11:48 am
by Patashu
Sometimes it's more useful to show how a number was arrived at than to just write the number. For example, if you had a 1024x768 game and wanted the constant '30 less than 1024', your intent is clearer if you write 1024-30 than if you write 994.
Why it's 0.15 / 1.5 specifically I don't know - maybe all emission values were divided by 1.5 at one point, and it's just been left like that since?
Re: Weird code in Electric Mining Drill?
Posted: Tue Aug 01, 2017 7:43 pm
by darkfrei
It can be just dividing or two parameters like by resistance
https://wiki.factorio.com/Damage
Re: Weird code in Electric Mining Drill?
Posted: Tue Aug 22, 2017 4:06 pm
by QGamer
So...I've been doing some modding of my own, and I noticed a few things:
1) Tons of entities have code like that. It's not limited to mining drills.
2) The pollution an entity emits is energy_source.emissions times the energy consumption in kW.
3) This format is useful for getting exact numbers of pollution. In a mod I'm making, I wanted an entity to output 15 pollution and consume 325 kW.
This:
...is in my opinion better than this: