narc0tiq / YARM

Yet another variant of the Resource Monitor for Factorio
https://mods.factorio.com/mod/YARM
MIT License
54 stars 42 forks source link

Add sort options for ore-count and ETD #105

Closed okradonkey closed 5 years ago

okradonkey commented 5 years ago

Important: Existing saved games with YARM sites try to access etd_minutes before it's set (null ref), so I added a failsafe in time_to_deplete (line 874: "or -1"). With the failsafe, there are no errors, but some sites display "ETD: never" for a few seconds until initialization. This may be better handled in the migration function.

Changes in this pull request: Added sort option for ore count Added sort option for ETD Added custom ETD message: "now" Moved ETD calculation to finish_deposit_count ETD is now accessible as site.etd_minutes etd_minutes value of -1 indicates ETD: Never (no miners depleting ore patch) etd_minutes value of 0 indicates ETD: Now (already completely depleted) ETD comparator sorts the list in proper order: Now .. X minutes .. Never (see comments in comparator function)

Capture

Note: I did not write any special code for infinite resources, but I am looking into a more accurate calculation for ETD (really, estimated time to minimum yield). I'll continue work on that in a separate branch soon.

narc0tiq commented 5 years ago

This is absolutely excellent, thank you very much! The failsafe is perfectly acceptable, especially since there might be more edge cases around creating a site or extending it.

I'll merge it as soon as I get a few minutes, and probably cut a release not long thereafter.

narc0tiq commented 5 years ago

Heh, I was sure there'd be edge cases: image

^ While trying to create a new site. Don't worry, I've got this.