So you want to change a table in BGEE.lua, right? You don't like the portraits that are in the list by default, you want to replace them with your own portrait pack's portraits. But you don't want to have to override the entire BGEE.lua file; what if an update comes out that changes that file? You want to be able to get all the juicy fixes.
We can help.
The v2.2 update adds native support for M_*.lua files. Drop any .lua file with a prefix of M_ into override, and the engine will load it just like BGEE.lua.
You can do a whole lot with an M_*.lua file. But today, let's focus on this fun thing: overwriting the contents of BGEE.lua, without having to overwrite ALL of BGEE.lua.
Start by opening BGEE.lua, and copy the entire portraits table into a new file. That whole file should look something like this:
Now, in that new file, let's get rid of all those portraits except for Neera's portrait and Dorn's portrait. We all love Neera and Dorn, right? Now the table should look like this:
Save that file as M_PORT.lua into your override folder. Now start the game and go into character creation; choose either gender, and you'll see that the list of available portraits has been completely overwritten!
You can also use an M_ file to overwrite variables, too; want to change a single fontcolor entry in the fontcolor table? Just put this into an M_ file:
fontcolors['1'] = 'FFCAE2E9' -- title
Change the value to whatever you want, save it, and it'll show up as the new color in-game.
Obviously, BGEE.lua contains more than just fonts and portraits, and that means you can do a lot more with M_*.lua files. But if you're working on UI mods, an M_ file can make the difference between "This mod will break after the next update" and "This mod will work with no problems even with future updates".