diff --git a/NEWS b/NEWS index 9cb34fcb8..a0e01dba1 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ DFHack future - embark: lets you embark anywhere. - lever: list and pull fort levers from the dfhack console. - stripcaged: mark items inside cages for dumping, eg caged goblin weapons. + - soundsense-season: writes the correct season to gamelog.txt on world load. New GUI scripts: - gui/guide-path: displays the cached path for minecart Guide orders. - gui/workshop-job: displays inputs of a workshop job and allows tweaking them. diff --git a/dfhack.init-example b/dfhack.init-example index 7617b9f6e..1a5aee48f 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -137,6 +137,13 @@ tweak military-color-assigned # remove inverse dependency of squad training speed on unit list size and use more sparring tweak military-training +########### +# Scripts # +########### + +# write the correct season to gamelog on world load +soundsense-season + ####################################################### # Apply binary patches at runtime # # # diff --git a/scripts/soundsense-season.lua b/scripts/soundsense-season.lua new file mode 100644 index 000000000..6b7d43cfa --- /dev/null +++ b/scripts/soundsense-season.lua @@ -0,0 +1,26 @@ +-- On map load writes the current season to gamelog.txt + +local seasons = { + [0] = 'Spring', + [1] = 'Summer', + [2] = 'Autumn', + [3] = 'Winter', +} + +local args = {...} + +local function write_gamelog(msg) + local log = io.open('gamelog.txt', 'a') + log:write(msg.."\n") + log:close() +end + +if args[1] == 'disable' then + dfhack.onStateChange[_ENV] = nil +else + dfhack.onStateChange[_ENV] = function(op) + if op == SC_WORLD_LOADED then + write_gamelog(seasons[df.global.cur_season]..' has arrived on the calendar.') + end + end +end