forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoundsense-season.lua
More file actions
34 lines (28 loc) · 901 Bytes
/
soundsense-season.lua
File metadata and controls
34 lines (28 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- On map load writes the current season to gamelog.txt
--[[=begin
soundsense-season
=================
It is a well known issue that Soundsense cannot detect the correct
current season when a savegame is loaded and has to play random
season music until a season switch occurs.
This script registers a hook that prints the appropriate string
to :file:`gamelog.txt` on every map load to fix this. For best results
call the script from :file:`dfhack.init`.
=end]]
local seasons = {
[-1] = 'Nothing', -- worldgen
[0] = 'Spring',
[1] = 'Summer',
[2] = 'Autumn',
[3] = 'Winter',
}
local args = {...}
if args[1] == 'disable' then
dfhack.onStateChange[_ENV] = nil
else
dfhack.onStateChange[_ENV] = function(op)
if op == SC_WORLD_LOADED then
dfhack.gui.writeToGamelog(seasons[df.global.cur_season]..' has arrived on the calendar.')
end
end
end