@@ -12,6 +12,10 @@ function isEnabled()
12
12
return enabled
13
13
end
14
14
15
+ local function is_fort_map_loaded ()
16
+ return df .global .gamemode == df .game_mode .DWARF and dfhack .isMapLoaded ()
17
+ end
18
+
15
19
local help = df .global .game .main_interface .help
16
20
17
21
local function close_help ()
@@ -39,36 +43,15 @@ function skip_tutorial_prompt()
39
43
end
40
44
end
41
45
42
- local function get_prefix ()
43
- if dfhack .world .isFortressMode () then
44
- return ' POPUP_'
45
- elseif dfhack .world .isAdventureMode () then
46
- return ' ADVENTURE_POPUP_'
47
- end
48
- end
49
-
50
46
local function hide_all_popups ()
51
- local prefix = get_prefix ()
52
- if not prefix then return end
53
47
for i ,name in ipairs (df .help_context_type ) do
54
- if not name :startswith (prefix ) then goto continue end
48
+ if not name :startswith (' POPUP_ ' ) then goto continue end
55
49
utils .insert_sorted (df .global .plotinfo .tutorial_seen , i )
56
50
utils .insert_sorted (df .global .plotinfo .tutorial_hide , i )
57
51
:: continue::
58
52
end
59
53
end
60
54
61
- local function show_all_popups ()
62
- local prefix = get_prefix ()
63
- if not prefix then return end
64
- for i ,name in ipairs (df .help_context_type ) do
65
- if not name :startswith (prefix ) then goto continue end
66
- utils .erase_sorted (df .global .plotinfo .tutorial_seen , i )
67
- utils .erase_sorted (df .global .plotinfo .tutorial_hide , i )
68
- :: continue::
69
- end
70
- end
71
-
72
55
dfhack .onStateChange [GLOBAL_KEY ] = function (sc )
73
56
if not enabled then return end
74
57
@@ -82,7 +65,7 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc)
82
65
dfhack .timeout (100 , ' frames' , skip_tutorial_prompt )
83
66
dfhack .timeout (1000 , ' frames' , skip_tutorial_prompt )
84
67
end
85
- elseif sc == SC_MAP_LOADED then
68
+ elseif sc == SC_MAP_LOADED and df . global . gamemode == df . game_mode . DWARF then
86
69
hide_all_popups ()
87
70
end
88
71
end
98
81
99
82
if args [1 ] == " enable" then
100
83
enabled = true
101
- if dfhack . isMapLoaded () then
84
+ if is_fort_map_loaded () then
102
85
hide_all_popups ()
103
86
end
104
87
elseif args [1 ] == " disable" then
105
88
enabled = false
106
- elseif args [1 ] == " reset" then
107
- show_all_popups ()
108
- elseif dfhack .isMapLoaded () then
89
+ elseif is_fort_map_loaded () then
109
90
hide_all_popups ()
110
91
else
111
- qerror (' hide-tutorials needs a loaded fortress or adventure map to work' )
92
+ qerror (' hide-tutorials needs a loaded fortress map to work' )
112
93
end
0 commit comments