local ModList
return Def.ActorFrame({
InitCommand = function(self)
ModList = dofile(ResolveRelativePath('mods.lua', 1))
for player = 0, 1 do
GAMESTATE:GetPlayerState(player):SetPlayerOptions('ModsLevel_Preferred', ModList.PreferredMods or '1x')
end
end,
OnCommand = function(self)
return self:queuecommand('ModReader')
end,
ModReaderCommand = function(self)
local copy
copy = function(value)
if type(value) ~= 'table' then
return value
end
local _tbl_0 = { }
for k, v in pairs(value) do
_tbl_0[k] = copy(v)
end
return _tbl_0
end
local mods = { }
for i = 1, #ModList do
do
local mod = ModList
table.insert(mods, mod)
if not mod.start and mod.after then
mod.start = ModList[i - 1].start + mod.after
end
if mod.repeatUntil or mod.repeatTimes then
local finish = mod.repeatUntil and mod.repeatUntil or mod.start + mod.repeatPeriod * (mod.repeatTimes - 1)
for beat = mod.start, finish, mod.repeatPeriod do
local repeatedMod
do
local _with_0 = copy(mod)
_with_0.start = beat
_with_0.repeatUntil = nil
_with_0.repeatPeriod = nil
repeatedMod = _with_0
end
table.insert(mods, repeatedMod)
end
end
end
end
for _index_0 = 1, #mods do
local mod = mods[_index_0]
if mod.lua and mod.lua.init then
mod.lua:init()
end
end
for _index_0 = 1, #mods do
local mod = mods[_index_0]
if GAMESTATE:GetSongBeat() > (mod.finish or mod.start + mod.len) then
mod.done = true
end
end
return self:SetUpdateFunction(function(self, delta)
local curBeat = GAMESTATE:GetSongBeat()
local p1mods = {
ModList.PreferredMods
}
local p2mods = {
ModList.PreferredMods
}
for _index_0 = 1, #mods do
local mod = mods[_index_0]
do
if not mod.finish and mod.len then
mod.finish = mod.start + mod.len
end
if curBeat >= mod.start and not mod.done then
if mod.mods then
if mod.player ~= PLAYER_2 then
table.insert(p1mods, mod.mods)
end
if mod.player ~= PLAYER_1 then
table.insert(p2mods, mod.mods)
end
end
if mod.lua then
if mod.luastarted and mod.lua.update then
local pos = math.min(1, (curBeat - mod.start) / (mod.finish - mod.start))
mod.lua:update(mod, pos, delta)
end
if mod.lua.start and not mod.luastarted then
mod.lua:start(mod)
end
if not mod.luastarted then
mod.luastarted = true
end
end
if curBeat >= mod.finish then
mod.done = true
if mod.lua and mod.lua.finish then
mod.lua:finish(mod)
end
end
end
end
end
p1mods = table.concat(p1mods, ',')
p2mods = table.concat(p2mods, ',')
GAMESTATE:GetPlayerState(PLAYER_1):SetPlayerOptions('ModsLevel_Song', p1mods)
GAMESTATE:GetPlayerState(PLAYER_2):SetPlayerOptions('ModsLevel_Song', p2mods)
local modsDisplay = self:GetChildren().modsDisplay
return modsDisplay:settext("Player 1 Mods: " .. tostring(p1mods) .. "\nPlayer 2 Mods: " .. tostring(p2mods))
end)
end,
LoadActor(GAMESTATE:GetCurrentSong():GetBackgroundPath()) .. {
OnCommand = function(self)
self:Center()
return self:scaletocover(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM)
end
}
})