Well, figured my own problem out. The structure isn't documented anywhere that I can find, although I was able to finally figure out how to use Lua to get the property names. Apparently it's called anon_1, presumably because it's not documented.
Well, no matter, I finished my first try at a Lua script. Here's the Lua script for marrying any two dwarves (or whatevers). I threw this together while teaching myself DFHack's API and Lua at the same time, so there is no error checking, and it doesn't use the fancy core suspension thing to make sure that the memory is consistent. It hasn't crashed the game for me yet, but certainly has the potential to. You've been warned.
-- Marries two specified creatures
local args = {...}
local victim1, historic_victim1
local victim2, historic_victim2
for key, value in pairs(df.global.world.units.all) do
-- The arguments are strings, but the structs contain numbers
if value.id == tonumber(args[1]) then
victim1 = value
end
if value.id == tonumber(args[2]) then
victim2 = value
end
end
print("Marrying " .. victim1.name.nickname .. " and " .. victim2.name.nickname)
historic_victim1 = df.global.world.history.figures[victim1.hist_figure_id]
historic_victim2 = df.global.world.history.figures[victim2.hist_figure_id]
local new_link1 = df.histfig_hf_link_spousest:new()
local new_link2 = df.histfig_hf_link_spousest:new()
-- Not documented, but this is the historical figure id
new_link1.anon_1 = victim2.hist_figure_id
new_link1.link_strength = 100
new_link2.anon_1 = victim1.hist_figure_id
new_link2.link_strength = 100
local link_count1 = #historic_victim1.histfig_links
local link_count2 = #historic_victim2.histfig_links
historic_victim1.histfig_links:resize(link_count1 + 1)
historic_victim1.histfig_links[link_count1] = new_link1
historic_victim2.histfig_links:resize(link_count2 + 1)
historic_victim2.histfig_links[link_count2] = new_link2
victim1.relations.spouse_id = victim2.id
victim2.relations.spouse_id = victim1.id
Just toss that in a file called marry.lua in your DFHack scripts folder. To use it, you'll need to run this command:
marry unit_id1 unit_id2
So you need to get those unit ids. The fastest way I know of to do that is to use the 'k' look around command and put it over each dwarf, then run this command inside the interactive Lua interpreter:
print(dfhack.gui.getSelectedUnit().id)
Do that for each dwarf, then run the marry command above and let the wedding bells ring. There's a lot that could be done to tweak the script, especially error checking and sanity checking. It will most certainly let you try to marry someone to multiple people (of either gender!), which will work for the relationships screen, but in the invisible relations section they're only really married to the last one you run through this command.
Next up is probably a divorce script, which should be pretty simple too.