DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.84k stars 463 forks source link

Jobs and references #4744

Open chdoc opened 1 week ago

chdoc commented 1 week ago

This adds a factory for general references and uses it in the Job module. Similar addGeneralRef wrappers can probably be added to the Unit and Buildings modules.

chdoc commented 6 days ago

Update: I now have a Lua script based on this that watches for units with high focus penalties for "Drink Alcohol" or "Eat Good Meal" (usually happens with citizen/resident Necromancers) and creates Drink or Eat jobs for them.

chdoc commented 5 days ago

I ran

local utils = require('utils')
for _,job in utils.listpairs(df.global.world.jobs.list) do
    local success = dfhack.job.removePostings(job,true)
end

(and also without the true) on one of my forts. This seems to correctly delete all job postings. On unpause, the game will happily restore postings for all jobs that need them (i.e. neither suspended nor having a worker assigned)