Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 244 245 [246] 247

Author Topic: DFHack 51.11-r1  (Read 957855 times)

Ziusudra

  • Bay Watcher
    • View Profile
Re: DFHack 51.05-r1
« Reply #3675 on: February 18, 2025, 08:41:15 pm »

Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

Maloy

  • Bay Watcher
    • View Profile
Re: DFHack 51.05-r1
« Reply #3676 on: February 19, 2025, 02:33:26 am »

is it:

unretire-anyone --dead


because I enter that and it pulls up the list, but I'm not seeing dead hist figures including my own dead adventurer


nvm got dead hist figures on it, but the list doesn't include dead adventurers for some reason
« Last Edit: February 19, 2025, 02:36:59 am by Maloy »
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 51.05-r1
« Reply #3677 on: February 20, 2025, 10:11:53 am »

Code: ('look.lua') [Select]
-- a script made to examine items from afar in adv mode this uses the adv mode's look cursor to function,
-- works best when keybinded to a button.
--uses warmists old vector search functions
local GMI=df.global.game.main_interface
local Advlook= GMI.adventure
local Sheets= GMI.view_sheets
Sheets.viewing_itid:resize(0)
function getItemAtPos(x,y,z) -- gets the item index @ x,y,z coord
--local x,y,z=getxyz() --get 'X' coords
local vector=df.global.world.items.all -- load all items
for i = 0, #vector-1 do -- look into all items offsets
local curpos=vector[i].pos --get its coordinates
local cx=curpos.x
local cy=curpos.y
local cz=curpos.z
if cx==x and cy==y and cz==z then --compare them
return vector[i] --return index
end
end
--print("item not found!")
return nil

end
function getxyz() -- this will return pointers x,y and z coordinates.
if Advlook.look.open==true then
local x=Advlook.look.cursor.x
local y=Advlook.look.cursor.y
local z=Advlook.look.cursor.z
return x,y,z -- return the coords
end
end
function sheetlooker(x,y,z)

Sheets.viewing_x=x
Sheets.viewing_y=y
Sheets.viewing_z=z
end

if Advlook.look.open==true then
sheetlooker(getxyz())

local examineitem=getItemAtPos(getxyz())
Sheets.viewing_itid:insert("#",examineitem.id)
Sheets.open=true
Sheets.active_sheet=6
end

ok this kinda became a bit of a bug bear so I went and whip up a script to restore the old examine items from afar feature that is missing in df51 adv mode.
to use this just use the look keyboard button and align the look cursor directly over the item you want to examine and run the script.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

myk

  • Bay Watcher
    • View Profile
Re: DFHack 51.05-r1
« Reply #3678 on: February 26, 2025, 06:46:49 pm »

DFHack 51.06-r1 is now available!

Highlights: Compatibility update

Get it from:

Manual installation instructions: https://docs.dfhack.org/en/stable/docs/Installing.html
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 51.06-r1
« Reply #3679 on: February 26, 2025, 09:33:53 pm »

Code: ("tofort20.lua") [Select]
-- changes from advmode to fort safely and back (hopefully)
--[[Now to warn you about saving and loading in either game mode might lead
    to some side issues, for saving in fort mode switching to adv mode needs the adv to be `bodyswap`
    back in again. for Saving in Adv to switch to Fort mode you probably be safe-ish if the site.
    isn't a nano fort or a site that isn't 3x3 small. otherwise the game will try to resize the map.
    oh and switching to fort mode on any pre-gen site larger than 4x4 might implode one pc if
    you don't have like 20 gigs of memory for the 16x16 embark size.

ok so this version of this script has be updated again so that caravans and visitors and migrants
could show up at any edge of the map... and maybe leave from any spot... of the z level you assign the site too.
should be warned while I mostly iron out the Caravan crash which ties into entities than anything that messes with plotinfo.
there still some unknowns left in the game
so uhh I probably should get to figuring out how to map the surface (properly) at some point...
should be said This is a modified copy of Warmist's Tofort script and this one is made for messing around the world.
there's a more Fort mode focus one called TopFort which dives into switching into player forts... and sometimes lord claimed campsites.

5/15/2024: rework the script to align to 50 new df structures and changed one designation clear function so it functions with out a cursor.
this wouldn't really work in 50 but maybe, there's potential chance of it working in the beta 51 build that has adv mode.
6/9/2024: unit.active[0] doesn't work so time to update this once again AGAIN
1/31/2025: updated this mess again again now having access to 51 proper going from fort mode to adv mode is risky and prone to crash,
but going from adv mode to fort mode should work and back.
probably don't use this on any saves you care about out of lingering fort mode plotinfo data and adventure mode data in the save that won't get cleared until you exit or play that game mode
2/26/2025: finally figure out how to get this script to work in fort mode to adv mode or toadv1 still probably consider this unstable but
now it works. this now hopefully swaps between adv mode and fort mode and has a select unit in fort mode to switch into adv mode with.
3/1/2025:ok had to edit this to make it so saves didn't break and one could adv party swap as I mistook the historical figure id for a unit id
]]--

if df.global.gamemode==df.game_mode.ADVENTURE then
local adv= df.global.world.units.adv_unit
local comp={}
local plotinfo=df.global.plotinfo

function advGlobalPos()
    local wd=df.global.world.world_data.midmap_data
    return wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y
end
function inSite()
    local tx,ty=advGlobalPos()
    for k,v in pairs(df.global.world.world_data.sites) do
        local tp2={v.global_min_x, v.global_min_y, v.global_max_x, v.global_max_y}
        if tx>=tp2[1] and tx<=tp2[3] and
            ty>=tp2[2] and ty<=tp2[4] then
            return v
        end
    end
end
local site=inSite()
if site==nil then
    qerror("No site you are in found.")
end
local nomad={}
local h_ent
--local test= tonumber(...)
if plotinfo.main.fortress_entity~=nil or plotinfo.main.fortress_site~=nil then
plotinfo.main.fortress_entity=nil
plotinfo.main.fortress_site=nil
end
--nomad=df.global.world.entities.all[test]
for k,v in pairs(df.global.world.history.figures[adv.hist_figure_id].entity_links) do
if v~=histfig_entity_link_memberst and not v==nil then
nomad=df.global.world.entities.all[v.entity_id]

print(test)
else if v==histfig_entity_link_memberst then
nomad=df.global.world.history.figures[adv.hist_figure_id].entity_links[0]
end
end
end

if plotinfo.main.fortress_entity==nil then
    for k,v in pairs(df.global.world.entities.all) do
        --if v.type==df.historical_entity_type.SiteGovernment and v.id==nomad.id then --maybe match race too?
        if v.id==nomad.id then --maybe match race too?
            if nomad.positions.own==nil then
break else
h_ent=v
            break
        end
        end
if v.id~=nomad.id then
if v.type==df.historical_entity_type.SiteGovernment then

h_ent=v
end
end
    end
    if h_ent==nil then
        qerror("Valid historical entity not found. sorry...")
    end
    plotinfo.main.fortress_entity=h_ent
else
    h_ent=plotinfo.main.fortress_entity
end

function cleardesignate(adv)
local scorch=df.global.world.map.map_blocks
    for k,v in pairs(scorch) do
if v.flags.designated==true then
v.flags.designated=false
end
    for k2,v2 in pairs(v.designation) do
    for k3,v3 in pairs(v2) do
if v3.dig>0 or v3.smooth>0 then
v3.dig=0
v3.smooth=0
end
end
end
end
dfhack.run_command('revflood')

end


function cleardesignateold(adv)
--local adv=df.global.world.units.active[0]
local adv= df.global.world.units.adv_unit
df.global.plotinfo.main.mode=10
df.global.selection_rect.start_x=0
df.global.selection_rect.start_y=0
df.global.selection_rect.start_z=610
df.global.selection_rect.end_x=-14300
df.global.selection_rect.end_y=9000
df.global.selection_rect.end_z=0
df.global.cursor.x=400
df.global.cursor.y=400
df.global.cursor.z=0
dfhack.gui.getCurViewscreen():feed_key(1)
df.global.cursor.x=adv.pos.x
df.global.cursor.y=adv.pos.y
df.global.cursor.z=adv.pos.z
dfhack.gui.getCurViewscreen():feed_key(1)
dfhack.run_command('revflood')

end
local carter={}
function addToEntity(entity,unit,addtoLead)
    local nem=dfhack.units.getNemesis(unit)
    local hfig=nem.figure
        for k,v in pairs(hfig.entity_links) do
if v.entity_id==entity.id then break else
carter=true
end
end
if carter==true then
hfig.entity_links:insert("#",{new=df.histfig_entity_link_memberst,entity_id=entity.id,link_strength=100})
    entity.nemesis_ids:insert("#",nem.id)
    entity.nemesis:insert("#",nem)
    entity.histfig_ids:insert("#",hfig.id)
    entity.hist_figures:insert("#",hfig)
end
    if addtoLead then
        local lead_id
        for k,v in pairs(entity.positions.own) do
            if v.flags.IS_LEADER==true then
                lead_id=v.id
                break
            end
        end
        if lead_id~=nil then
            for k,v in pairs(entity.positions.assignments) do
                if v.position_id==lead_id  then
                        v.histfig=hfig.id
                    break
                end
            end
        end
    end
end

plotinfo.civ_id=adv.civ_id
plotinfo.race_id=adv.race
df.global.pause_state=true


plotinfo.usable_stockpile_race:insert("#",adv.race)
plotinfo.site_id=site.id
if plotinfo.main.fortress_site==nil then plotinfo.main.fortress_site=site end
if site.entity_links==nil then site.entity_links:insert("#", {new=true, df.entity_site_link, target=site.id, entity_id=plotinfo.fortress_entity.id,entity_site_link_flags.residence, entity_site_link_flags.trade_partner }) end
plotinfo.group_id=h_ent.id
plotinfo.game_state=2


if #plotinfo.tasks.discovered_plants==0 then
df.global.plotinfo.tasks.discovered_creature_foods:insert("#",0)
df.global.plotinfo.tasks.discovered_creatures:insert("#",0)
df.global.plotinfo.tasks.discovered_plants:insert("#",0)
df.global.plotinfo.tasks.discovered_plant_foods:insert("#",0)
end
if #plotinfo.alerts.list==0 then
    plotinfo.alerts.list:insert("#",{new=true,name="Dummy alert"})
    plotinfo.alerts.next_id=1
end


    local nem2=dfhack.units.getNemesis(adv)
    local hfig2=nem2.figure
    local nomad2=hfig2.entity_links[0]
    local nomad3=hfig2.entity_links
    local Test={}
    for co2,mp2 in pairs(nomad3) do
--print(mp2.entity_id,h_ent.id)
        if mp2.entity_id~=h_ent.id then Test=true else
            Test=false
            end
        end   
        if Test==true then
            addToEntity(h_ent,adv,true)
        end
    for co,mp in pairs(df.global.world.units.active) do
if mp.population_id==h_ent.id then
mp.flags2.resident=false
end
if mp.civ_id==h_ent.id or adv.civ_id==mp.civ_id then
mp.flags2.resident=false
end
        if mp.relationship_ids.GroupLeader==adv.id then
            local comp=mp
        if Test==true then
            addToEntity(h_ent,comp,false)
        end
    end
end
function filleco(tbl,low,high)
  for v =low, high do
    tbl.general_items:insert("#",2)
  end
     tbl.weapons:insert("#",2)
    tbl.armor:insert("#",2)
    tbl.handwear:insert("#",2)
    tbl.footwear:insert("#",2)
    tbl.legwear:insert("#",2)
    tbl.headwear:insert("#",2)
    tbl.prepared_food:insert("#",2)
    tbl.wood:insert("#",2)
    tbl.thread_cloth:insert("#",2)
    tbl.paper:insert("#",2)
    tbl.parchment:insert("#",2)
    tbl.bone:insert("#",2)
    tbl.tooth:insert("#",2)
    tbl.horn:insert("#",2)
    tbl.pearl:insert("#",2)
    tbl.shell:insert("#",2)
    tbl.leather:insert("#",2)
    tbl.silk:insert("#",2)
    tbl.yarn:insert("#",2)
    tbl.inorganic:insert("#",2)
    tbl.meat:insert("#",2)
    tbl.fish:insert("#",2)
    tbl.plants:insert("#",2)
    tbl.drinks:insert("#",2)
    tbl.extract_animal:insert("#",2)
    tbl.mill_animal:insert("#",2)
    tbl.cheese_animal:insert("#",2)
    tbl.extract_plant:insert("#",2)
    tbl.mill_plant:insert("#",2)
    tbl.cheese_plant:insert("#",2)
    tbl.pets:insert("#",2)

end
function filleco2(tbl,low,high)
  for v =low, high do
    tbl.general_items:insert("#",nil)
  end
 
     tbl.weapons:insert("#",nil)
    tbl.armor:insert("#",nil)
    tbl.handwear:insert("#",nil)
    tbl.footwear:insert("#",nil)
    tbl.legwear:insert("#",nil)
    tbl.headwear:insert("#",nil)
    tbl.prepared_food:insert("#",nil)
    tbl.wood:insert("#",nil)
    tbl.thread_cloth:insert("#",nil)
    tbl.paper:insert("#",nil)
    tbl.parchment:insert("#",nil)
    tbl.bone:insert("#",nil)
    tbl.tooth:insert("#",nil)
    tbl.horn:insert("#",nil)
    tbl.pearl:insert("#",nil)
    tbl.shell:insert("#",nil)
    tbl.leather:insert("#",nil)
    tbl.silk:insert("#",nil)
    tbl.yarn:insert("#",nil)
    tbl.inorganic:insert("#",nil)
    tbl.meat:insert("#",nil)
    tbl.fish:insert("#",nil)
    tbl.plants:insert("#",nil)
    tbl.drinks:insert("#",nil)
    tbl.extract_animal:insert("#",nil)
    tbl.mill_animal:insert("#",nil)
    tbl.cheese_animal:insert("#",nil)
    tbl.extract_plant:insert("#",nil)
    tbl.mill_plant:insert("#",nil)
    tbl.cheese_plant:insert("#",nil)
    tbl.pets:insert("#",nil)

end

function fill(tbl,low,high)
  for v =low, high do
    tbl:insert("#",0)
    tbl:insert("#",v)
    tbl:insert("#",143)
    tbl:insert("#",v)
  end
end
function fill2(tbl,low,high)
  for v =low, high do
    tbl:insert("#",v)
    tbl:insert("#",143)
    tbl:insert("#",v)
    tbl:insert("#",0)
  end
end
function fillz(tbl,low,high)
  for v =low, high do
    tbl:insert("#",adv.pos.z)
    tbl:insert("#",adv.pos.z)
    tbl:insert("#",adv.pos.z)
    tbl:insert("#",adv.pos.z)
  end
end
function fillunk(tbl,low,high)
  for v =low, high do
    tbl[v].x=site.pos.x
    tbl[v].y=site.pos.y
  end
end
function fillanimal(tbl,low,high)
  for v =low, high do
    tbl:insert("#",1)
  end
end
function fillstone(tbl,low,high)
  for v =low, high do
    tbl:insert("#",0)
  end
end

function fillTrain(tbl,tbl2,low,high)
  for v =low, high do
    tbl2:insert("#",0)
tbl:insert("#",5)
  end
end


function mapcheck2()

fill(df.global.plotinfo.wilderpop_enter.x,0,143)
fill2(df.global.plotinfo.wilderpop_enter.y,0,143)
fillz(df.global.plotinfo.wilderpop_enter.z,0,143)

fill(df.global.plotinfo.map_edge.surface_x,0,143)
fill2(df.global.plotinfo.map_edge.surface_y,0,143)
fillz(df.global.plotinfo.map_edge.surface_z,0,143)

for _,Lay in pairs(df.global.plotinfo.map_edge.layer_x) do

fill(Lay,0,143)
end
for _,Lay in pairs(df.global.plotinfo.map_edge.layer_y) do
fill2(Lay,0,143)
end
for _,Lay in pairs(df.global.plotinfo.map_edge.layer_z) do
fillz(Lay,0,143)
end
end
function sigh()
 mapcheck()
 mapcheck2()
for k,v in pairs(df.global.plotinfo.wilderpop_enter.x) do

end
for k,v in pairs(df.global.plotinfo.map_edge.surface_z) do
df.global.plotinfo.map_edge.surface_z[k]=adv.pos.z
--v=152
end
end
function mapcheck()
fillunk(df.global.plotinfo.border[0],0,143)
fillunk(df.global.plotinfo.border[1],0,143)
fillunk(df.global.plotinfo.border[2],0,143)
fillunk(df.global.plotinfo.border[3],0,143)

end
Tab={}
Tab2={}
for k,Lay2 in pairs(df.global.plotinfo.map_edge.layer_z) do
for k2,Lay3 in pairs(df.global.plotinfo.border[0]) do
if k then break else
Tab:insert("#",k)
end
Tab2:insert("#",k2)
return Tab,Tab2
end
end
if #df.global.plotinfo.map_edge.layer_z[0] == 0 then
print("map edge empty proceed to fill")
sigh()
 else
print("welp map edge currently full")
 end

 if plotinfo.main.fortress_entity.squads==0 then
for Sqa,Ds in pairs (df.global.world.squads.all) do
if Ds.entity_id==plotinfo.main.fortress_entity.id then
plotinfo.main.fortress_entity.squads:insert("#",{new=true,Ds})
end
end
end
if #plotinfo.tasks.discovered_plants==0 then

--for k,Lay2 in ipairs(df.global.world.raws.creatures.all) do
--return k
--end
local Anim=#df.global.world.raws.creatures.all
local Plan=#df.global.world.raws.plants.all
fillanimal(df.global.plotinfo.tasks.discovered_creatures,0,Anim)
fillanimal(df.global.plotinfo.tasks.discovered_creature_foods,0,Anim)

fillanimal(df.global.plotinfo.tasks.discovered_plants,0,Plan)
fillanimal(df.global.plotinfo.tasks.discovered_plant_foods,0,Plan)
--for k,Lay2 in ipairs(df.global.world.raws.plants.all) do
--return k
--end
--end
end
function fillTrain(tbl,tbl2,low,high)
  for v =low, high do
    tbl2:insert("#",0)
tbl:insert("#",5)
  end
end


 
if #plotinfo.kitchen.item_types==0 then
plotinfo.kitchen.item_types:insert("#",0)
plotinfo.kitchen.item_subtypes:insert("#",0)
plotinfo.kitchen.mat_types:insert("#",0)
plotinfo.kitchen.mat_indices:insert("#",0)
--plotinfo.kitchen.exc_types:insert("#",df.kitchen_exc_typest)
end
if #plotinfo.infiltrator_histfigs==0 then
plotinfo.infiltrator_histfigs:insert("#",0)
plotinfo.infiltrator_histfigs:insert("#",0)
plotinfo.infiltrator_years:insert("#",0)
plotinfo.infiltrator_years:insert("#",0)
plotinfo.infiltrator_year_ticks:insert("#",0)
plotinfo.infiltrator_year_ticks:insert("#",0)
end
if #plotinfo.economic_stone==0 then
for k,Lay2 in ipairs(df.global.world.raws.inorganics) do
fillstone(df.global.plotinfo.economic_stone,0,k)
--return k
end
end


if #plotinfo.economy_prices.price_adjustment.general_items==0 then

filleco(df.global.plotinfo.economy_prices.price_adjustment,0,114)
filleco2(df.global.plotinfo.economy_prices.price_setter,0,114)

end
--fix training info
if h_ent.training_knowledge == nil then
    h_ent.training_knowledge={new=true}
end
if #plotinfo.main.fortress_entity.training_knowledge.level==0  then
local Anim=#df.global.world.raws.creatures.all
fillTrain(plotinfo.main.fortress_entity.training_knowledge.level,plotinfo.main.fortress_entity.training_knowledge.skill_points,0,Anim-1)
end

df.global.gamemode=df.game_mode.DWARF
df.global.gametype=df.game_type.DWARF_MAIN
if df.global.gview.view.child.child==nil then df.global.gview.view.child=df.viewscreen_dwarfmodest:new()
df.global.gview.view.child.parent=df.global.gview.view
 end
 cleardesignate()
    print("Mode change complete.")
else
    local adv2=dfhack.gui.getSelectedUnit(true)
    local adv=df.global.world.units.adv_unit
    if adv==nil or adv~=adv2 and adv2~=nil then
        --swap units...
local swap=df.global.adventure
if #swap.interactions.party_core_members==0 then
swap.interactions.party_core_members:insert("#",adv2.id)
else
swap.interactions.party_core_members[0]=adv2.id
end
if swap.player_id==-1 then
swap.player_id=df.global.world.history.figures[adv2.hist_figure_id].nemesis_id
end
local adv2nem=df.global.world.history.figures[adv2.hist_figure_id].nemesis_id
for advk,advlay in ipairs(df.global.world.nemesis.all) do
if advlay.flags.ACTIVE_ADVENTURER==false and advlay.id==adv2nem then
advlay.flags.ACTIVE_ADVENTURER=true
advlay.flags.ADVENTURER=true
end
end
df.global.world.units.adv_unit=dfhack.gui.getSelectedUnit(true)
df.global.gview.view.child=df.viewscreen_dungeonmodest:new()
df.global.gview.view.child.parent=df.global.gview.view
df.global.gamemode=df.game_mode.ADVENTURE
df.global.gametype=df.game_type.ADVENTURE_MAIN
    else
df.global.gview.view.child=df.viewscreen_dungeonmodest:new()
df.global.gview.view.child.parent=df.global.gview.view
df.global.gamemode=df.game_mode.ADVENTURE
df.global.gametype=df.game_type.ADVENTURE_MAIN

    print("Mode change complete.")
end
end



ok the Tofort script has been updated for 51 again this time fixing the issue of going from fort mode to adv mode it can now hop in both game modes now.
still unknowingly unstable and you are still switching into adv mode thus leaving your fort to 'retire' in a sense
edit: ok there was one hiccup that took a while to realize I was editing on the older build of the script.
« Last Edit: March 01, 2025, 12:54:18 pm by Rumrusher »
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

brewer bob

  • Bay Watcher
  • euphoric due to inebriation
    • View Profile
Re: DFHack 51.06-r1
« Reply #3680 on: March 08, 2025, 07:12:01 am »

A couple DFHack 0.47.05-r8 questions related to a generated world/existing save:

Is it possible to add to a site government new positions that were not defined in raws when the world was generated? (E.g., add a new "manager" type of position to a human civ.)

If so, is it possible to do with gm-editor and what changes would this require and where? (I don't know scripting, so I'd be doing this manually.)

And is the process different with an entity that has SITE_VARIABLE_POSITIONS:ALL than one that doesn't?

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Re: DFHack 51.06-r1
« Reply #3681 on: March 09, 2025, 12:29:14 am »

Maybe?  Knowledge of some basic Lua would be helpful.

So.  You're looking to add a new position to a human civ, i.e. a civ generated using the vanilla PLAINS entity, that has [VARIABLE_POSITIONS:ALL] set in the raws.  Or are you dealing with a modded entity?

Do you have any OTHER human civilizations that have the position?  That would be helpful to crib from.

Civilizations are stored in df.global.world.entities.all .  This is a huge vector (array) that contains not only Civilizations but also Site Governments, Religions, Entertainer Troupes, and more.  Your first issue will be finding your target civ in it.

This is easy if you have a unit on-screen from that civ.  Just highlight, invoke gui/gm-editor, and look at the .civ_id field.  That's the index you need.

Otherwise, you'll need to use Lua.  This will give you the candidates:

Code: [Select]
:lua for i,civ in ipairs(df.global.world.entities.all) do if civ.type == 0 and civ.entity_raw.code == "PLAINS" then print(i, dfhack.TranslateName(civ.name)); end; end;
You can then use gm-editor to inspect those entries in df.global.world.entities.all and find your target.

Having found your target civ, you can inspect its .positions.own vector.  Take a good look at the entries, and decide if you want to continue.  I'll continue to help.

And it even looks possible to specify a historical figure that holds the position.  That's stored in .positions.assignments

(And... I just figured out how to shut off mandates entirely.  Nice.)
Logged

brewer bob

  • Bay Watcher
  • euphoric due to inebriation
    • View Profile
Re: DFHack 51.06-r1
« Reply #3682 on: March 09, 2025, 06:44:12 am »

Maybe?  Knowledge of some basic Lua would be helpful.

My knowledge is limited to somewhat understanding what's going on in a script. (Not much understanding of the coding part since the last time I tried anything was with BASIC and Turbo Pascal in the nineties. And that was just typing in code from some magazine. :P)

So.  You're looking to add a new position to a human civ, i.e. a civ generated using the vanilla PLAINS entity, that has [VARIABLE_POSITIONS:ALL] set in the raws.  Or are you dealing with a modded entity?

Humans were the main idea, yes, but I was also possibly thinking of doing something similar with other (mostly) vanilla entities. The thing is that when I generated the world I wasn't expecting to possibly want to play with these civs, so the whole idea was to add some positions to them in a human player fort that would be equivalent to what dwarves have (e.g., manager, etc).

Had to actually check if it's modded (been playing 2,5 years on the same world) and there's a bit of modding going on. PLAINS still has variable positions, but seems like I've added a guild representative from Modest Mod, which is a civ level position. No idea if that's any help.


Quote
Do you have any OTHER human civilizations that have the position?  That would be helpful to crib from.

Not really. But even copying any kind of position would be helpful, since I could just change the flags and names.

Quote
Civilizations are stored in df.global.world.entities.all .   
--snip--

Yeah, I've been checking the civ/site government id's from units, so that much I can at least do. :)

Quote
Having found your target civ, you can inspect its .positions.own vector.  Take a good look at the entries, and decide if you want to continue.  I'll continue to help.

Alright, I'll check this and see what kind of problems I run into. (Trying this on a backup save, so no worries.)

Thanks for the help, much appreciated!

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Re: DFHack 51.06-r1
« Reply #3683 on: March 09, 2025, 07:47:51 pm »

Okay.  So you want to add MANAGER positions and the like.  And you already have some way to make PLAINS civilizations playable, when they were non-playable when the world was generated.  Right?

Maybe you want to just copy all of the positions from a MOUNTAIN race civilization?  Or, better, pick-and-choose which ones to copy?

That could probably be done in Lua.  Trying to do this through gm-editor... it would be possible, I suppose, but very tedious and error-prone.

A big issue would be keeping the raws in sync.  Maybe that doesn't matter though.  It looks like civ entities get saved/loaded in whole, maybe they don't refer back to the raws.  Worth trying.

Might have to obliterate the modded GUILD_REPRESENTATIVE position.  No big loss.  Could cause some flakiness if the position is filled in your target civ.

Does this sound right?
Logged

brewer bob

  • Bay Watcher
  • euphoric due to inebriation
    • View Profile
Re: DFHack 51.06-r1
« Reply #3684 on: March 10, 2025, 07:21:19 am »

Okay.  So you want to add MANAGER positions and the like.  And you already have some way to make PLAINS civilizations playable, when they were non-playable when the world was generated.  Right?

Yes. Making them playable is a simple matter of adding SITE_CONTROLLABLE to the entity raws. This is one of the raw edits that works in generated worlds.

Ideally I'd like to learn how to make new positions in a generated world to any of the civs (dwarves, elves, humans, etc.). If such a thing is possible, of course.

(Normally I'd just generate a new world and mod it with raws, but since it's a long-running world that I want to stick with, I'm trying to figure how much I can edit the existing world. Also, I'm pretty certain there's others out there who'd like to know if adding positions to existing worlds is possible.)

Maybe you want to just copy all of the positions from a MOUNTAIN race civilization?  Or, better, pick-and-choose which ones to copy?

I tried out something similar and looked up a human site's lord (CUSTOM_LAW_MAKER) and manually copied it to (the site government).positions.own. Added a new entity_position to the blank screen with alt+i. But this isn't apparently enough, or I did something wrong, which is possible (nothing shows up in the nobles screen).

So, I assume I have to make an entry in positions.assignments, and this is where I run into problems. For a new site, this screen is blank, so I tried adding a new entity_position_assignment with alt+i, which adds it. However, when editing the entity_position_assignment, it has a part called 'flags' <BitArray ....> . This screen is empty in the one I added. In existing assignments flags contains true/false fields (or whatever they're called) from 0-31.

So, if I try to manually add a new one to the empty assigment flags, I crash to desktop.

I was thinking of trying out if I add to the human parent civ (before embarking) site specific positions (that is to <civ>positions.site.) and see if it creates the position assignments to the new site. Haven't yet tested this, but if it works, it wouldn't require messing around with the assignment fields.

Quote
That could probably be done in Lua.  Trying to do this through gm-editor... it would be possible, I suppose, but very tedious and error-prone.

Yeah, I guess I should start learning lua (which has been in the plans for a bit too long). But I'm also fine with tedious manual entries.

Quote
A big issue would be keeping the raws in sync.  Maybe that doesn't matter though.  It looks like civ entities get saved/loaded in whole, maybe they don't refer back to the raws.  Worth trying.

I actually tried editing existing raw defined positions in a dwarf player fortress (such as changing names). Saving and loading didn't seem to change these, so it might be that they aren't checked from the raws once they've been made to the site? Just my guess.

Quote
Might have to obliterate the modded GUILD_REPRESENTATIVE position.  No big loss.  Could cause some flakiness if the position is filled in your target civ.

The human civs have these positions assigned, so it's possible it'll cause issues. I could try it and see what happens.

Anyway, thanks!

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Re: DFHack 51.06-r1
« Reply #3685 on: March 10, 2025, 05:21:48 pm »

So, I assume I have to make an entry in positions.assignments, and this is where I run into problems. For a new site, this screen is blank, so I tried adding a new entity_position_assignment with alt+i, which adds it. However, when editing the entity_position_assignment, it has a part called 'flags' <BitArray ....> . This screen is empty in the one I added. In existing assignments flags contains true/false fields (or whatever they're called) from 0-31.

So, if I try to manually add a new one to the empty assigment flags, I crash to desktop.

I could not replicate this.  I find a human civ entity, open it, open positions, open assignments, press Alt-I, type entity_position_assignment, open the entry I just created, open flags, and press Alt-I four times, and I get 32 entries named 0 through 31.

I can save and reload without crashing, and the edit sticks.  So.  Try again?  Except:

First of all, you probably need to do your edits BEFORE creating a new site.

Second, it looks like you'll have to copy a position.site, and probably NOT a position.assignments .
« Last Edit: March 10, 2025, 05:44:45 pm by 0x517A5D »
Logged

brewer bob

  • Bay Watcher
  • euphoric due to inebriation
    • View Profile
Re: DFHack 51.06-r1
« Reply #3686 on: March 10, 2025, 05:37:51 pm »

So, I assume I have to make an entry in positions.assignments, and this is where I run into problems. For a new site, this screen is blank, so I tried adding a new entity_position_assignment with alt+i, which adds it. However, when editing the entity_position_assignment, it has a part called 'flags' <BitArray ....> . This screen is empty in the one I added. In existing assignments flags contains true/false fields (or whatever they're called) from 0-31.

So, if I try to manually add a new one to the empty assigment flags, I crash to desktop.

I could not replicate this.  I find a human civ entity, open it, open positions, open assignments, press Alt-I, type entity_position_assignment, open the entry I just created, open flags, and press Alt-I four times, and I get 32 entries named 0 through 31.

I can save and reload without crashing.  So.  Try again?  Except:

First of all, you probably need to do your edits BEFORE creating a new site.

Second, it looks like you'll have to copy a position.site, and probably NOT a position.assignments .

Alright, I just tested alt+i to entity_position_assignment flags and... it didn't crash. I don't know what went wrong previously(it crashed on three tries)?

I'll do more testing tomorrow and see if I get the stuff to work.

Thanks again!

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Re: DFHack 51.06-r1
« Reply #3687 on: March 10, 2025, 08:19:42 pm »

Here's how I did it in a new, almost vanilla world:

Spoiler (click to show/hide)

It worked.

Edit: as I thought, you need to add a new positions.site entry, and leave alone positions.assignments.

Edit2 for posterity.  At some point between that DFHack version and the current DFHack version, the Lua function dfhack.TranslateName() was changed to dfhack.translation.translateName() .
« Last Edit: March 10, 2025, 08:34:52 pm by 0x517A5D »
Logged

brewer bob

  • Bay Watcher
  • euphoric due to inebriation
    • View Profile
Re: DFHack 51.06-r1
« Reply #3688 on: March 11, 2025, 06:20:56 am »

Here's how I did it in a new, almost vanilla world:

-- snip --

It worked.

Thanks! This helped a lot!

I'll test and see if this causes any issues in the long run.

myk

  • Bay Watcher
    • View Profile
Re: DFHack 51.07-r1
« Reply #3689 on: March 12, 2025, 07:39:17 pm »

DFHack 51.07-r1 is now available!

Highlights: Adventure mode journal, Fish tank mode, Skip adventure messages, Attach notes to the map, Advanced cheese making

Get it from:

Manual installation instructions: https://docs.dfhack.org/en/stable/docs/Installing.html
Logged
Pages: 1 ... 244 245 [246] 247