Advertisement
Guest User

save_current.lua

a guest
Aug 23rd, 2015
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. -- path is where the file lives relative to StepMania's root.
  2. local path = "Save/_freezone/CurrentSong.txt"
  3.  
  4. local function player_current_song_stats(pn)
  5.     local outStr = ""
  6.     local song = GAMESTATE:GetCurrentSong();
  7.     if song then
  8.         -- attach song dir
  9.         local songDir = song:GetSongDir()
  10.         outStr = outStr .. "\"" .. songDir .. "\""
  11.         -- attach stepstype and difficulty
  12.         local steps = GAMESTATE:GetCurrentSteps(pn)
  13.         if steps then
  14.             local st = string.gsub(ToEnumShortString(steps:GetStepsType()),"_","-")
  15.             local diff = ToEnumShortString(steps:GetDifficulty())
  16.             outStr = outStr .. " " .. st .. " " .. diff
  17.         end;
  18.         -- attach rate mod
  19.         local sOptions = GAMESTATE:GetSongOptionsObject("ModsLevel_Song")
  20.         if sOptions then
  21.             local sRate = sOptions:MusicRate()
  22.             outStr = outStr .. " " .. sRate
  23.         end;
  24.         return outStr
  25.     end
  26. end
  27.  
  28. function write_current_song_stats()
  29.     local str= ""
  30.     if GAMESTATE:IsCourseMode() then return end
  31.     for pn in ivalues(GAMESTATE:GetHumanPlayers()) do
  32.         str= str .. player_current_song_stats(pn)
  33.     end
  34.     local file= RageFileUtil.CreateRageFile()
  35.     if not file:Open(path, 2) then
  36.         Warn("Could not open '" .. path .. "' to write current playing info.")
  37.     else
  38.         file:Write(str)
  39.         file:Close()
  40.         file:destroy()
  41.     end
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement