Advertisement
Jousway

taro mod

Oct 7th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.57 KB | None | 0 0
  1.  
  2. -- luacheck: globals Def GAMESTATE SCREENMAN
  3.  
  4. local DefaultMods = '1.5x, overhead'
  5.  
  6. -- format:  { <beat>, 'len' or 'end', <len or end time>, <mod string>, <player number (optional, if not here, applies to all players)> }
  7. -- example: { 0, 'len', 9999, '*0.5 200% dizzy' }
  8. local SongMods = {
  9. }
  10.  
  11. -- format: { <beat>, <command> }
  12. local LuaMods = {
  13. }
  14.  
  15. -- helper function to convert beats -> seconds
  16. local function TimeInBeats(beats)
  17.   return 60 / 147 * beats
  18. end
  19.  
  20. -- player for keeping tables for EZ access
  21. local Players = {}
  22.  
  23. return Def.ActorFrame {
  24.    -- DO NOT TOUCH ANY OF THIS UNLESS YOU KNOW WHAT YOU'RE DOING
  25.   InitCommand = function (self)
  26.     -- table to keep track of mods already finished
  27.     local completed = {}
  28.  
  29.     -- for edit mode, go through and mark the ones already passed
  30.     -- if we don't do this, weird shit happens
  31.     for i, mod in ipairs(SongMods) do
  32.       local modbeat, paramtype, param, modstring = unpack(mod)
  33.       local modfinish = paramtype == 'end' and param
  34.         or paramtype == 'len' and modbeat + param
  35.         or error('invalid parameter type ' .. paramtype .. ' for mod #' .. i .. '(mod string: ' .. modstring .. ')')
  36.  
  37.       if GAMESTATE:GetSongBeat() > modfinish then
  38.         completed[mod] = true
  39.       end
  40.     end
  41.     for _, mod in ipairs(LuaMods) do
  42.       local beat = unpack(mod)
  43.       if GAMESTATE:GetSongBeat() > beat then
  44.         completed[mod] = true
  45.       end
  46.     end
  47.  
  48.     -- hOBOI
  49.     self:SetUpdateFunction(function()
  50.       local curbeat = GAMESTATE:GetSongBeat() + 0.08
  51.       local curmods = {}
  52.  
  53.       for i=1, GAMESTATE:GetNumPlayersEnabled() do
  54.         curmods[i] = { DefaultMods }
  55.       end
  56.  
  57.       for i, mod in ipairs(SongMods) do
  58.         if not completed[mod] then
  59.           local modbeat, paramtype, param, modstring, player = unpack(mod)
  60.           local modfinish = paramtype == 'end' and param
  61.             or paramtype == 'len' and modbeat + param
  62.             or error('invalid parameter type ' .. paramtype .. ' for mod #' .. i .. '(mod string: ' .. modstring .. ')') -- typos happen
  63.  
  64.           if curbeat >= modbeat then
  65.             for p, playermods in ipairs(curmods) do
  66.               if player == nil or player == p then
  67.                 table.insert(playermods, modstring)
  68.               end
  69.             end
  70.             if curbeat > modfinish then
  71.               completed[mod] = true
  72.             end
  73.           end
  74.         end
  75.       end
  76.  
  77.       for p, playermods in ipairs(curmods) do
  78.         GAMESTATE:GetPlayerState('PlayerNumber_P' .. p):SetPlayerOptions('ModsLevel_Song', table.concat(playermods, ','))
  79.       end
  80.  
  81.       -- this is significantly easier *sigh*
  82.       for _, mod in ipairs(LuaMods) do
  83.         local beat, command = unpack(mod)
  84.         if curbeat > beat and not completed[mod] then
  85.           self:playcommand(command, unpack(mod, 3))
  86.           completed[mod] = true
  87.         end
  88.       end
  89.     end)
  90.   end,
  91.  
  92.   OnCommand = function (self)
  93.     table.insert(Players, SCREENMAN:GetTopScreen():GetChild('PlayerP1'))
  94.     table.insert(Players, SCREENMAN:GetTopScreen():GetChild('PlayerP2'))
  95.  
  96.     -- because edit mode is so nice as to not name the playfields,
  97.     -- we have to grab them ourselves! ;)
  98.     for _, actor in ipairs(SCREENMAN:GetTopScreen():GetChild('')) do
  99.       if tostring(actor):find('Player') then
  100.         table.insert(Players, actor)
  101.       end
  102.     end
  103.  
  104.     -- reset player state (for edit mode)
  105.     for _, player in ipairs(Players) do
  106.       player:stoptweening():zoom(1)
  107.     end
  108.  
  109.     -- keep the FG change alive
  110.     self:sleep(9999)
  111.   end,
  112. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement