How is crude-oil resource yield calculated?

Place to get help with not working mods / modding interface.
Theanderblast
Inserter
Inserter
Posts: 46
Joined: Fri Aug 19, 2016 2:48 pm
Contact:

How is crude-oil resource yield calculated?

Post by Theanderblast »

I've written a mod called Max Rate Calculator, which provides a selection tool you can use on a set of machines, and it calculates the net throughput rates, considering the beacons, modules, etc.

I've been asked to extend this to include mining-drills. For ores, it's relatively simple (though I haven't looked at uranium miners and the sulfuric acid inputs), but when the entity's mining_target is crude-oil, how can I calculate the units produced per second? The tooltip shows a 'yield' percentage, and I can see from the wiki how to get from that to production rate, but how is that percentage calculated?

Thanks in advance...
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How is crude-oil resource yield calculated?

Post by eradicator »

Code: Select all

/c
local that = game.player.selected
game.print('This oil field has '.. math.floor((that.amount/that.prototype.normal_resource_amount)*100) ..'% yield.')
Though for internal calculations you shouldn't math.floor() it, that's just to make the printout look nice.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Theanderblast
Inserter
Inserter
Posts: 46
Joined: Fri Aug 19, 2016 2:48 pm
Contact:

Re: How is crude-oil resource yield calculated?

Post by Theanderblast »

eradicator wrote:

Code: Select all

/c
local that = game.player.selected
game.print('This oil field has '.. math.floor((that.amount/that.prototype.normal_resource_amount)*100) ..'% yield.')
Though for internal calculations you shouldn't math.floor() it, that's just to make the printout look nice.
Many thanks!
Post Reply

Return to “Modding help”