Sorry to bring this up again, but I have a similar problem that appears related to the auto-block DLC bug/feature. This time the issue isn't Lua execution, but some kind of database refresh. Here's the context, in three steps.
1. I have a difficulty mod for BNW. My custom difficulties are working, but by default they can only be selected via Advanced Setup. See the mod in post #1 of this thread, which adds dummy difficulties Hello and World! after Deity. (The Lua in that mod is never loaded, so just ignore it.)
2. As mentioned in previous posts, I want my custom difficulty levels on the basic setup screen. This is possible using auto-block DLC if I block G&K in my mod. Users who don't have G&K installed will need to use Advanced Setup to set difficulty. Additionally, I want to remove the standard difficulty levels (Settler - Deity). Deleting standard difficulties would lead to a crash-to-desktop when starting the game, but following
the advice here and reindexing HandicapInfos using SQL avoids a crash. This works perfectly provided that G&K is installed and can be auto-blocked, see attached mod below.
3. However, if G&K isn't installed, the SQL update somehow screws up the stuff that was working in step 1 - no more custom difficulties in Advanced setup. Try it by loading my test mod again with G&K disabled.
Why does this get messed up? I assume that auto-block DLC not only triggers a reload of Lua code, but also somehow refreshes the database. Strangely (for me), only deletions require this refresh. Inserts work anyway, as evidenced by the XML additions.
On the bright side, the problem occurs in Advanced Setup - which is moddable with Lua. Can I trigger this mysterious refresh myself in Lua somehow?