To be clear: what I'm looking to do is to substitute certain monster IDs for other monster IDs on a given map load, replacing entirely one monster for another. Adjusting monster parameters/attributes/abilities isn't what I'm looking to do.
It's trivial enough to do what I want by editing lodfiles, but that's not the correct solution for my needs (since lodfile changes would get clobbered by the randomizer in patched lods mode).
I thought it looked weird the way I did it before (I'm out of practice with lua; I used to know that but got roped into languages that don't do that)BTW, it didn't work because without parentheses lua applied not to var (not returns only true or false, so the result will never be nil). If you wrote `if not (var == nil)` it would work too. For future reference, for learning basic syntax you can use programming in lua course, one version of which is available online for free or, if you don't have that much time, most basic language/syntax concepts are explained by lua cheatsheets, like this one (I'm not promoting it, this was my first google result for "lua cheat sheet").