forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quicksave.lua
42 lines (34 loc) · 1.17 KB
/
quicksave.lua
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
-- Makes the game immediately save the state.
local gui = require("gui")
--luacheck: defclass={run:bool}
QuicksaveOverlay = defclass(QuicksaveOverlay, gui.Screen)
function QuicksaveOverlay:render()
if not self.run then
self.run = true
save()
self:renderParent()
self:dismiss()
end
end
if not dfhack.isMapLoaded() then
qerror("World and map aren't loaded.")
end
if not dfhack.world.isFortressMode() then
qerror('This script can only be used in fortress mode')
end
function save()
local ui_main = df.global.plotinfo.main
-- Request auto-save (preparation steps below discovered from rev eng)
ui_main.autosave_request = true
ui_main.autosave_timer = 5
ui_main.save_progress.substage = 0
ui_main.save_progress.stage = 0
ui_main.save_progress.info.nemesis_save_file_id:resize(0)
ui_main.save_progress.info.nemesis_member_idx:resize(0)
ui_main.save_progress.info.units:resize(0)
ui_main.save_progress.info.cur_unit_chunk = nil
ui_main.save_progress.info.cur_unit_chunk_num = -1
ui_main.save_progress.info.units_offloaded = -1
print 'The game should autosave now.'
end
QuicksaveOverlay():show()