Hey guys, longtime player/luker/fan of DF and all her utilities.
Couple questions:
How interested would you guys be in an updated(graded) make-monarch script?
I've used the underlying logic to make the script applicable to all noble positions in entity.positions.own ("MONARCH", "DUKE", "COUNT", "BARON", "DIPLOMAT", "GENERAL", "LIEUTENANT", "CAPTAIN", "OUTPOST_LIAISON") and made it so that you can "demote" a unit without raising another.
local args = {...}
local argv = # args
function GetPositionID(entity, str)
local POSITIONS = {"MONARCH", "DUKE", "COUNT", "BARON", "DIPLOMAT",
"GENERAL", "LIEUTENANT", "CAPTAIN", "OUTPOST_LIAISON"}
local isValid = false
for i=0, 9 do
if POSITIONS[i] == str then
isValid = true
end
end
if not isValid then
qerror("Noble position '" .. str .. "' is not valid.")
end
for k, v in pairs(entity.positions.own) do
if v.code == str then
return v.id
end
end
return nil
end
function Demote(entity, posID)
for assignID, v in pairs(entity.positions.assignments) do
if v.position_id == posID then
local histFigOld = df.historical_figure.find(v.histfig)
if not histFigOld then
return
end
v.histfig = 0
for k,v in pairs(histFigOld.entity_links) do
local isInstance = df.histfig_entity_link_positionst:is_instance(v)
if isInstance and v.assignment_id == assignID and v.entity_id == df.global.ui.civ_id then
histFigOld.entity_links:erase(k)
return
end
end
end
end
end
function Promote(entity, posID, histFig)
for assignID, v in pairs(entity.positions.assignments) do
if v.position_id == posID then
v.histfig = histFig.id
histFig.entity_links:insert("#",
{new=df.histfig_entity_link_positionst,
entity_id=df.global.ui.civ_id,
link_strength=100,
assignment_id=assignID,
start_year=df.global.cur_year})
return
end
end
end
function Main()
local unit = dfhack.gui.getSelectedUnit()
if not unit then
qerror("Please select a unit.")
end
local histFig = dfhack.units.getNemesis(unit).figure
local ownEntity = df.historical_entity.find(df.global.ui.civ_id)
local posID = GetPositionID(ownEntity, string.upper(args[1]))
if not posID then
qerror("Could not find position ID.")
end
local isDemoting = false
if argv > 1 then
if string.lower(args[2]) == "demote" then
isDemoting = true
end
end
if isDemoting then
if not dfhack.units.isOwnGroup(unit) then
print("Can only demote this fort's units.")
else
Demote(ownEntity, posID)
end
else
Demote(ownEntity, posID)
Promote(ownEntity, posID, histFig)
end
end
Main()
(dead group barons borking my site's progression and "inhereted" barons were the impetus for the script if you were wondering).
I noticed the github repo doesn't have a contributing guidelines, so here I am rather than just doing a PR. Also the original make-monarch doesn't have any licensing attached to it, so while I'd be happy to release under a GNU GPLv3 I'm not quite sure if that's kosher.
With the above script in mind; What do we know about the event(s) concering elevating a fortress (barony/county/duchy)?
Ideally, I'd like to have the script elevate the fort if you assign a position you're not yet on, but I've failed in finding anything relevant.