I have a problem with function dfhack.units.getVisibleName() in lua script.
When I want the script to show real name, I use simply
string.gsub(unit.first_name,"^%l",string.upper)
When I wanted to show fake name, I tried this:
string.gsub(dfhack.units.getVisibleName(unit).first_name,"^%l",string.upper)
However, the last code still shows the same real first name as the first one (and thus reveals an identity of a vampire). According to description the function should show the fake name, right? So why would it show the real one?
And the reason for that is that flags2.killed is the one that tells if a unit is dead. All killed units are inactive, but all inactive units are not killed (e.g. inbound/outbound). Also consider whether you actually need to access the flags directly, or can use the Units.isKilled/.isActive/.isMerchant etc. functions instead.
After the rename I just changed the names of flags in my scripts from "flags1.dead " to "flags1[1]", so they will work with both names under different dfhacks. Problems with functions is that you need to test them first, because they are not always working as expected. Using a flag is quicker and less stressful, if you know what it's supposed to do.