diff options
| author | Alexander Gavrilov | 2012-08-29 19:20:38 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-08-29 19:20:38 +0400 |
| commit | cb125f3d89382c4c075ea69d5178868c6e325938 (patch) | |
| tree | 5edbc2719164a644e2e89588f6d16a27ff421421 /scripts | |
| parent | 8a617edb10c79671255ad8cb7d757ab0d0faec64 (diff) | |
| download | dfhack-cb125f3d89382c4c075ea69d5178868c6e325938.tar.gz dfhack-cb125f3d89382c4c075ea69d5178868c6e325938.tar.bz2 dfhack-cb125f3d89382c4c075ea69d5178868c6e325938.tar.xz | |
Add a script to fix population cap problems.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/devel/migrants-now.lua | 9 | ||||
| -rw-r--r-- | scripts/fix/population-cap.lua | 40 |
2 files changed, 49 insertions, 0 deletions
diff --git a/scripts/devel/migrants-now.lua b/scripts/devel/migrants-now.lua new file mode 100644 index 00000000..8eb4b0c8 --- /dev/null +++ b/scripts/devel/migrants-now.lua @@ -0,0 +1,9 @@ +-- Force a migrants event in next 10 ticks. + +df.global.timed_events:insert('#',{ + new = true, + type = df.timed_event_type.Migrants, + season = df.global.cur_season, + season_ticks = df.global.cur_season_tick+1, + entity = df.historical_entity.find(df.global.ui.civ_id) +}) diff --git a/scripts/fix/population-cap.lua b/scripts/fix/population-cap.lua new file mode 100644 index 00000000..a34098c5 --- /dev/null +++ b/scripts/fix/population-cap.lua @@ -0,0 +1,40 @@ +-- Communicates current population to mountainhomes to avoid cap overshooting. + +-- The reason for population cap problems is that the population value it +-- is compared against comes from the last dwarven caravan that successfully +-- left for mountainhomes. This script instantly updates it. +-- Note that a migration wave can still overshoot the limit by 1-2 dwarves because +-- of the last migrant bringing his family. Likewise, king arrival ignores cap. + +local args = {...} + +local ui = df.global.ui +local ui_stats = ui.tasks +local civ = df.historical_entity.find(ui.civ_id) + +if not civ then + qerror('No active fortress.') +end + +local civ_stats = civ.activity_stats + +if not civ_stats then + if args[1] ~= 'force' then + qerror('No caravan report object; use "fix/population-cap force" to create one') + end + print('Creating an empty statistics structure...') + civ.activity_stats = { + new = true, + created_weapons = { resize = #ui_stats.created_weapons }, + known_creatures1 = { resize = #ui_stats.known_creatures1 }, + known_creatures = { resize = #ui_stats.known_creatures }, + known_plants1 = { resize = #ui_stats.known_plants1 }, + known_plants = { resize = #ui_stats.known_plants }, + } + civ_stats = civ.activity_stats +end + +-- Use max to keep at least some of the original caravan communication idea +civ_stats.population = math.max(civ_stats.population, ui_stats.population) + +print('Home civ notified about current population.') |
