Skip to content

Rawset the entirety of Battle.LUA

NerduMiner requested to merge nerdyminer18/srb2p-public:globalized-battle into next

Everything, including tables have been rawset so no matter where and how they are redefined, no one part of the battle system requires any other to be in the same file. addHooks have also had their functions rawset, so external redefinition is possible.

Most benefits are directed towards the modding community. While few mods have need to edit Battle code, those that do have to contend with the fact that most, if not every bit of battle code requires another part, in which that part requires another part, etc. The result is mods carrying a battle related lua file hundreds of kilobytes large where about ~60% or less of the code is actually relevant to the mod.

The above metric was taken from an experiment where the popular Teamsize mod was edited to work under the new philosophies of this PR. In specifics, ~53kb of code was effectively removed from the mod, as it was only there because other parts of battle code needed it, the once ~140kb large file is now only ~88kb, and all of it is relevant to the changes the mod needs to make.

This is definitely not the be all end all solution for every issue that arises with mods editing Battle code, but it simplifies the process of mods updating to match new features in the Battle code between updates(I did not have fun working on three mods at once that contained every bit of battle code in order to get parity with 1.3.5), and makes editing the system a much more accessible process when required.

I'm not convinced that there are any downsides with rawsetting everything here, if there are I'd appreciate being told about them, since I haven't noticed any problems during my testing.

Merge request reports