I'm trying to rename a Civilisation, but can't figure out what I need to do to get its reference in the lua. Could anyone help me out?
If you can select a unit belonging to that civ, you could get at the civ name like so:
local u=dfhack.gui.getSelectedUnit()
if u then
print("Selected unit has civ_id of "..u.civ_id.."...")
if u.civ_id == -1 then
print('How uncivilized!')
else
local civ = df.global.world.entities.all[u.civ_id]
print('Entity #'..u.civ_id..' is '..dfhack.TranslateName(civ.name)..', "'..dfhack.TranslateName(civ.name,1)..'", '..civ.type)
end
end
Otherwise, you'll need to use pairs to go through df.global.world.entities.all until you find the one you want.
Managed to find it, thanks! The first ID (civ_id=) was not the same as its reference in global.world.entities, but the global.world.entities where all listed numerically so it was just a case of finding the linear offset.
After that, the actual words used are taken from the Dwarven Language file, with each incriment of 1 being by line. A lot of non-culled words didn't turn up due to word case, so I just had to switch between the different language modes to get the one I wanted (very easy, it ranges between like 0 and 3) and the word turned up. When the word wasn't turning up, it was only in the translation, the name would still have change even though the translation didnt, allowing me to make sure I had the right word. Language settings of 0 and 1 are the most likely to show the word.