-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.lua
More file actions
79 lines (64 loc) · 2.26 KB
/
start.lua
File metadata and controls
79 lines (64 loc) · 2.26 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
local play = require('configuration/play')
local currentTas = play['currentTas']
local homeRunScripts
if currentTas == 'home-run-mode' then
homeRunScripts = require('scripts/home-run')
local f = io.open('db/home_run.db', 'r')
if f ~= nil then
io.close(f)
else
homeRunScripts.prepareDatabase()
end
end
local loadSlot = play['loadSlot']
local paths = require('configuration/paths')
local files = {}
local cFiles = require(paths['files'])
if (cFiles[currentTas] ~= nil) then
for _, file in ipairs(cFiles[currentTas]) do
files[#files + 1] = table.concat({ paths['tas'], currentTas, file }, '/')
end
end
-- Retrieve the inputs of the current tas
local joypadSet = require('core/input').merge(files)
-- Preload a savestate, if exists
local preloads = require(paths['preloads'])
if (preloads[currentTas] ~= nil) then
savestate.load(table.concat({ paths['savestate'], preloads[currentTas] }, '/'))
end
-- Load the current savestate, if defined and exists
if (loadSlot ~= nil) then
savestate.loadslot(loadSlot)
end
-- Add overlays
local mediator = require('mediator')()
if 'home-run-mode' == currentTas then
require('plugins/overlay/home-run-mode').applySubscriptions(mediator)
else
require('plugins/overlay/collection').applySubscriptions(mediator)
end
-- Screenshot configuration
local screenshotConfiguration = require(paths['screenshot'])
if ('home-run-mode' == currentTas and play['home-run-mode']['benchmark'] and play['home-run-mode']['show-benchmark-overlay'])
or ('home-run-mode' == currentTas and not play['home-run-mode']['benchmark'] and play['home-run-mode']['show-overlay'])
then
client.SetGameExtraPadding(0, 0, 350, 0)
else
client.SetGameExtraPadding(0, 0, 0, 0)
end
while (true) do
-- Retrieve the current frame ...
local fc = emu.framecount()
-- ... then dispatch it (for overlays) ...
mediator:publish({ 'frame.displayed' }, fc)
-- ... then "push" the inputs (if inputs are set for this frame) ...
if (joypadSet[fc]) then
joypad.set(joypadSet[fc])
end
-- ... then do a screenshot if set for this frame ...
if (screenshotConfiguration[fc]) then
client.screenshot(screenshotConfiguration[fc])
end
-- ... and forward to the next frame
emu.frameadvance()
end