renoth / factorio-factory-levels

MIT License
4 stars 3 forks source link

[Idea/feature request] Make levels as invisible modules or smth #40

Open malomaster opened 1 year ago

malomaster commented 1 year ago

Despite the good idea, this mod has one fatal flaw: performance impact. Because it adds many entities – copies of every machine, mod greatly affects performance on late-game; moreover, if you playing with lots of mods with complex production chains (Bob, Angel, Py etc.), it affects even on mid-game. So I think maybe if you make machine levels not as different entities for every machine, but something like an invisible module with level bonuses attached to machines, it will be more UPS-friendly? Moreover, level module instead of different entities for every level will fix an issue with power statistics mentioned in #35 because all machines of one tier will be grouped together like without "Factory levels" mod and will not divide by levels for each group.

renoth commented 1 year ago

Thats a good idea, do you know how to program an invisible module in factorio? The API is not very friendly to leveling up entities. Maybe with the quality API that is coming with the addon this mod can be implemented in a more efficient way.

malomaster commented 1 year ago

Sorry, but I'm a total novice in LUA and in coding in general (for example, only one week ago I learned how to make multilayered icons by external patching). The maximum that I can do is copy-paste something (item, entity or so), a little tweak another mod directly or by external data.raw patch. Or make RU translation. And not all of them working, for example, I don't know how to patch 5Dim's mods, because direct data.raw patches in data-final-fixes just doesn't working for any 5Dim mod's entities.

About invisible modules, with my so little LUA knowledge, I think, you need to add a new hidden property (class?) to type "assembling-machine", maybe a subproperty to "module_specification", so it will not be shown on machine's GUI or in hints as slot module, as well as the level module itself. Also you need GUI hook that will add a level icon (it can be just a number on a some picture or something like army ranks with tooltip on mouse hover – current level, bonuses etc.) on machine GUI. I don't know how to code all this, as well as what method you need to use when create level modules. I don't think, that just creating only 100 level modules (items and entities) and replacing them by next on machine level up will work because different types and tiers of machines have different level bonuses, and if mod will create 100 entities on every assembling machine type, I think, it will be ≈ the same as now, with 100 levels of every machine. So I think level bonuses formulas must be stored in a table, and, when the machine produced the first item, level module just load bonuses formula, apply them on the machine and then only on machine level up calls an update function to recalculate current bonuses. But I still don't know if it will work or not. At least try to contact with more experienced mod-makers, maybe someone will help.