Skip to content

Commit

Permalink
Strip out any potentially leftover periods in score and rate. Also re…
Browse files Browse the repository at this point in the history
…move extra whitespace from HashGenerator.lua
  • Loading branch information
teejusb authored and quietly-turning committed May 20, 2019
1 parent 1e611be commit 156e55c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ if not GAMESTATE:IsCourseMode() and (SL.Global.GameMode == "Competitive" or
local PercentDP = stats:GetPercentDancePoints()

local score = FormatPercentScore(PercentDP)
score = tostring(tonumber((score:gsub("%%", ""))) * 100)
score = tostring(tonumber(score:gsub("%%", "") * 100)):gsub("%.", "")
local failed = stats:GetFailed() and "1" or "0"
local rate = tostring(SL.Global.ActiveModifiers.MusicRate * 100)
local rate = tostring(SL.Global.ActiveModifiers.MusicRate * 100):gsub("%.", "")

local currentSteps = GAMESTATE:GetCurrentSteps(player)
local difficulty = ""
Expand Down Expand Up @@ -69,4 +69,4 @@ if not GAMESTATE:IsCourseMode() and (SL.Global.GameMode == "Competitive" or
}

return pane
end
end
12 changes: 6 additions & 6 deletions Scripts/SL-HashGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local function MinimizeChart(ChartString)
-- generated by StepMania. This is okay because the charts would still
-- be considered equivalent.
-- E.g. 0000 0000
-- 0000 -- minimized to -->
-- 0000 -- minimized to -->
-- 0000
-- 0000
-- StepMania will always generate the former since quarter notes are
Expand All @@ -16,29 +16,29 @@ local function MinimizeChart(ChartString)
-- If every other line is all 0s, we can minimize the measure.
local allZeroes = true
for i=2, #measure, 2 do
-- Check if the row is NOT all zeroes (thus we can't minimize).
-- Check if the row is NOT all zeroes (thus we can't minimize).
if measure[i] ~= string.rep('0', measure[i]:len()) then
allZeroes = false
break
end
end

if allZeroes then
-- To remove every other element while keeping the
-- indices valid, we iterate from [2, len(t)/2 + 1].
-- See the example below (where len(t) == 6).

-- index: 1 2 3 4 5 6 -> remove index 2
-- value: a b a b a b

-- index: 1 2 3 4 5 -> remove index 3
-- value: a a b a b

-- index: 1 2 3 4 -> remove index 4
-- value: a a a b

-- index: 1 2 3
-- value: a a a
-- value: a a a
for i=2, #measure/2+1 do
table.remove(measure, i)
end
Expand Down Expand Up @@ -121,4 +121,4 @@ function GenerateHash(stepsType, difficulty)
end

return ''
end
end

0 comments on commit 156e55c

Please sign in to comment.