Open PiggyWhiskey opened 9 months ago
i'd like to integrate this with proper attribution. mind forking the repo to your account, making a commit there, and starting a pull request from there?
I can do that, I want to fix the lack of localised resource name though for some reason site.ore_name doesn't return any value, although it's used fine in printing to the player. site.ore_type returns the object name iron-ore though, but it's not the best.
It also would need more work to have a site 'ID' to allow an automatic increment, possibly check if current_site.name exists in the data list
The issue with cross-surface resource sites in the same co-ords still breaks the values as well, so the unique names won't fix it.
I want to fix the lack of localised resource name though
Well, it's easy enough to look up the docs on LocalisedString but what you're really running into is that it's an all-or-nothing situation: the site name must be either a raw string or a localized string, and due to Lua, it really has to be a raw string (because it's a table key!).
What I would suggest is that you remove the site name from display completely, internally generate it to be as unique as possible (could be surface + x/y would be enough) and add a separate site.display_name
that the player can set freely with any content they like*. You can ask Factorio to give you raw text from a localised string** (using a specific player's locale, so it's deterministic), and you should know which player is adding the site so you can use them for the initial naming.
You can even leave it as a LocalisedString until a player tries to change it, but that might be too confusing for multilingual multiplayer servers ("Why did 'Eisenerz' change to 'Iron ore' when Mr.X renamed the site?").
The issue with cross-surface resource sites in the same co-ords
That one comes from the ore tracker using the x/y coordinates as the table key: https://github.com/narc0tiq/YARM/blob/072291cd134b86a948a8a9eb1ecc5f50b574d734/libs/ore_tracker.lua#L35-L40
You will want to change it so position_to_string
also takes a surface parameter and make a migration that updates the old ones -- remember the ore tracker has the entity itself so ask the entity to tell you its surface.
To be perfectly honest, given the changes in Factorio savegames since YARM v0.7.15 (i.e., before Factorio 0.14!), it might be better to remove the ore tracker altogether and go back to storing the actual entities in the site. All this crap (meaning resmon.migrate_ore_sites
) is a workaround for the fact that, at the time, it was making loading times increase massively if you had lots of entity references in your global data -- and then, by the time the ore_tracker came around, that was all fine again and we were mitigating other problems, which have probably also been fixed.
* Any content the player likes, including duplicates -- I should be able to have 5 "Base" sites for my 5 resources in the starting area.
** Slight wrinkle in this is that request_translation
doesn't directly return anything, but raises on_string_translated
instead -- you will have a tick or two where the display name is unavailable and you'll have to have a way to link the translated string back to the site whose name it's supposed to be when the translation does come in.
Seems like a re-write of how it stores the resource fields might be better
The other issue with using center coordinates is an ore patch surrounding another patch will have the same center
Maybe the sites should stored like: UniqueID Surface Resource Type Resource Name Tick Added Entities[]
other calculated fields Total Quantity ETD etc
Then a few functions to find the sites needed get_site_by_id(siteID get_site_by_surface(surface, [resourceType]) get_site_by_location(surface, resourceType, location[x,y])
I saw there was a YARM2 branch, is that happening?
I saw there was a YARM2 branch, is that happening?
I haven't worked on YARM in years, that's why I was happy that @wchristian is willing to take over maintenance.
YARM2 hasn't made it past the basic concept stage; what I did manage to get running is the part where you craft a thing like a fake miner that you put on the ore patch, and it counts the ore for you (using invisible circuit wires to an invisible pole, because that's the only way to get the numbers out).
I really liked that concept since it's basically not having to do its own counting but I hated the invisible pole because it could get left behind somehow (is it actually possible to register a fully dependent entity? That gets destroyed when the main one does?).
The other part I didn't like is this doesn't really help for oil fields, or any other sparse resource, and I have several options I didn't like for that:
global
.But I never got around to implementing any of these and it's just decayed in the 3 years since. Maybe if the Factorio expansion motivates me to get back to modding I'll make another go of YARM2 -- ever since miners got the ability to output an ore patch summary to circuit network I've always wanted to use that somehow.
On a very related note, a different thing I wanted was to make a generic circuit network monitor -- basically YARM, but using a circuit-connected device and thus able to monitor literally anything. I got some progress on https://github.com/narc0tiq/prodmon (maybe should be named circuit-monitor?) but it didn't retain my attention enough to get through to a minimum-releasable.
Part of the concept for YARM2 was to enable some UI goodness like grouping and summaries, as well as local configurability since there would be a proper entity to attach to; prodmon would have had something similar as you'd want to filter what is actually tracked, configure what "full" means, and other options that could make it a really useful tool overall. There is a mod called production monitor (or something similar) but that uses the production statistics whereas prodmon, despite the name, would just be about whatever circuit signals you could craft, and could mean anything.
But my Factorio time has dwindled over the years and everything stalled. I kept hoping someone would pick up the resource monitor idea and make their own (as I did to follow up the 3 similar monitors from ancient Factorio that got discontinued), but apparently YARM is somewhere where it's just good enough for the people who want a monitor and can write mods, so it's just stagnated as-is.
If you want to make a go of it, you're welcome to both my ideas and any of my code that you can use: we're open source here, we love forks.
I don't have permission to submit a pull request, so here it is:
resmon.lua Replace lines 527-530 with
settings.lua Add
locale/en/base.cfg Add
These changes will allow players to add custom naming conventions, and prevent the common issue of sites being removed due to the same automatic name being used