Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathhide-tutorials.lua
More file actions
Latest commit
112 lines (97 loc) · 3.13 KB
/
Copy pathhide-tutorials.lua
File metadata and controls
112 lines (97 loc) · 3.13 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
--@module = true
--@enable = true
localgui=require('gui')
localutils=require('utils')
localGLOBAL_KEY='hide-tutorials'
enabled=enabledorfalse
functionisEnabled()
returnenabled
end
localhelp=df.global.game.main_interface.help
localfunctionclose_help()
help.open=false
end
functionskip_tutorial_prompt()
ifnothelp.openthenreturnend
localscr=dfhack.gui.getDFViewscreen(true)
localmouse_y=23
ifhelp.context==df.help_context_type.EMBARK_TUTORIAL_CHOICEthen
help.context=df.help_context_type.EMBARK_MESSAGE
-- dialog behavior changes for the button click, but the button is still
-- in the "tutorial choice" button position
mouse_y=18
end
ifhelp.context==df.help_context_type.EMBARK_MESSAGEthen
df.global.gps.mouse_x=df.global.gps.dimx//2
df.global.gps.mouse_y=mouse_y
gui.simulateInput(scr, '_MOUSE_L')
end
ifhelp.openthen
-- retry later
help.context=df.help_context_type.EMBARK_TUTORIAL_CHOICE
end
end
localfunctionget_prefix()
ifdfhack.world.isFortressMode() then
return'POPUP_'
elseifdfhack.world.isAdventureMode() then
return'ADVENTURE_POPUP_'
end
end
localfunctionhide_all_popups()
localprefix=get_prefix()
ifnotprefixthenreturnend
fori,nameinipairs(df.help_context_type) do
ifnotname:startswith(prefix) thengotocontinueend
utils.insert_sorted(df.global.plotinfo.tutorial_seen, i)
utils.insert_sorted(df.global.plotinfo.tutorial_hide, i)
::continue::
end
end
localfunctionshow_all_popups()
localprefix=get_prefix()
ifnotprefixthenreturnend
fori,nameinipairs(df.help_context_type) do
ifnotname:startswith(prefix) thengotocontinueend
utils.erase_sorted(df.global.plotinfo.tutorial_seen, i)
utils.erase_sorted(df.global.plotinfo.tutorial_hide, i)
::continue::
end
end
dfhack.onStateChange[GLOBAL_KEY] =function(sc)
ifnotenabledthenreturnend
ifsc==SC_VIEWSCREEN_CHANGEDthen
localscr=dfhack.gui.getDFViewscreen(true)
ifdf.viewscreen_new_regionst:is_instance(scr) then
close_help()
elseifdf.viewscreen_choose_start_sitest:is_instance(scr) then
skip_tutorial_prompt()
dfhack.timeout(10, 'frames', skip_tutorial_prompt)
dfhack.timeout(100, 'frames', skip_tutorial_prompt)
dfhack.timeout(1000, 'frames', skip_tutorial_prompt)
end
elseifsc==SC_MAP_LOADEDthen
hide_all_popups()
end
end
ifdfhack_flags.modulethen
return
end
localargs= {...}
ifdfhack_flagsanddfhack_flags.enablethen
args= {dfhack_flags.enable_stateand'enable' or'disable'}
end
ifargs[1] =="enable" then
enabled=true
ifdfhack.isMapLoaded() then
hide_all_popups()
end
elseifargs[1] =="disable" then
enabled=false
elseifargs[1] =="reset" then
show_all_popups()
elseifdfhack.isMapLoaded() then
hide_all_popups()
else
qerror('hide-tutorials needs a loaded fortress or adventure map to work')
end