Skip to content

Instantly share code, notes, and snippets.

@freem
Created January 31, 2015 01:07
Show Gist options
  • Save freem/2dfb19f2c7555d7e3a46 to your computer and use it in GitHub Desktop.
Save freem/2dfb19f2c7555d7e3a46 to your computer and use it in GitHub Desktop.
SOMS2 score export, created 2010/08/09; last edit 2011/06/27
--[[
ExportScoreForIRC is something that AJ made for fun. It requires an
understanding of how StepMania views your filesystem, as well as knowledge
on how to make your IRC client play from a script file.
Since this was made for a limited purpose, it assumes you play as a single player
in non-course modes.
It spits out a string like this:
last played: $SONG by $ARTIST ($SONGGROUP) [$MODE $DIFFICULTY] $PERCENT | $W1 / $W2 / $W3 / $W4 / $W5 / $MISS | Holds: ($HELD/DROPPED) Max Combo: $MAXCOMBO
Place this code somewhere in a ScreenEvaluation BGAnimation (underlay, overlay,
decorations, whatever).
This requires FileUtils, which is built into sm-ssc and new SM5.
You can use this code with StepMania 4 alpha 5 if you have the standalone
FileUtils from http://kki.ajworld.net/misc/FileUtils.lua
This is Version 0.2.
The latest version can be found at http://kki.ajworld.net/misc/ExportScoreForIRC.lua
Changelog:
v0.2
* added song group
v0.1
* initial "release"
setting up IRC
this is going to be different for each client. I only have mIRC on hand to test
this with.
[mIRC]
Open the Scripts Editor, go to the Aliases tab and paste this on its own line:
/smlastplayed /me $read("D:\sm-ssc\_freezone\LastPlayed.txt") $$1-
where "D:\sm-ssc\_freezone\LastPlayed.txt" is the path to the LastPlayed.txt
file. Please also edit local path below if changing the folder from "_freezone".
[General]
Since StepMania/sm-ssc can only read and write files from within its ecosystem,
it's important that you make the location of LastPlayed.txt as simple as possible
(and not likely to get removed by the uninstaller when upgrading).
--]]
local mp = GAMESTATE:GetMasterPlayerNumber();
-- path is where the file lives relative to StepMania's root.
local path = "_freezone/LastPlayed.txt"
return Def.ActorFrame{
Def.Actor{
OnCommand=function(self)
-- this assumes normal mode only.
if not GAMESTATE:IsCourseMode() then
local outStr = "last played: "
local song = GAMESTATE:GetCurrentSong();
if song then
-- attach song title/artist
local mainTitle = song:GetDisplayFullTitle()
local artist = song:GetDisplayArtist()
outStr = outStr .. mainTitle .." by "..artist
-- attach song group
local songGroup = song:GetGroupName()
outStr = outStr .. " ("..songGroup..")"
-- attach stepstype and difficulty
local steps = GAMESTATE:GetCurrentSteps(mp)
if steps then
local st = string.gsub(ToEnumShortString(steps:GetStepsType()),"_","-")
local diff = ToEnumShortString(steps:GetDifficulty())
outStr = outStr .." [".. st .." ".. diff .."] "
end;
local sStats = STATSMAN:GetCurStageStats()
local pStats = sStats:GetPlayerStageStats(mp)
-- attach percent score
local pScore = pStats:GetPercentDancePoints()*100
outStr = outStr ..string.format("%.02f%%",pScore)
-- attach judge counts
local w1 = pStats:GetTapNoteScores('TapNoteScore_W1')
local w2 = pStats:GetTapNoteScores('TapNoteScore_W2')
local w3 = pStats:GetTapNoteScores('TapNoteScore_W3')
local w4 = pStats:GetTapNoteScores('TapNoteScore_W4')
local w5 = pStats:GetTapNoteScores('TapNoteScore_W5')
local miss = pStats:GetTapNoteScores('TapNoteScore_Miss')
outStr = outStr .." | "..w1.." / "..w2.." / "..w3.." / "..w4.." / "..w5.." / "..miss
-- attach OK/NG counts
local held = pStats:GetHoldNoteScores('HoldNoteScore_Held')
local dropped = pStats:GetHoldNoteScores('HoldNoteScore_LetGo')
outStr = outStr .." / Holds: ("..held .." / ".. dropped ..")"
-- attach max combo
local maxCombo = pStats:MaxCombo();
local comboThreshold = THEME:GetMetric("Gameplay","MinScoreToContinueCombo")
local gotFullCombo = pStats:FullComboOfScore(comboThreshold);
local comboLabel = gotFullCombo and "Full" or "Max"
outStr = outStr .." ".. comboLabel .." Combo: ".. maxCombo
-- write string
File.Write(path,outStr)
end
end
end;
};
};
-- this code is in the public domain because I don't really care about
-- copyrighting something like this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment