#20 I think this is it.
authorCameron Ball <c.ball1729@gmail.com>
Fri, 13 Dec 2013 04:12:51 +0000 (12:12 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Fri, 13 Dec 2013 04:12:51 +0000 (12:12 +0800)
Themes/GrooveNights/Scripts/Other.lua
Themes/GrooveNights/Scripts/SpeedMods.lua

index f9afa38..d1033d7 100644 (file)
@@ -454,7 +454,7 @@ function DisplayBPM(pn)
     local lowBPM = GetGlobal("LowBPM")
     local highBPM = GetGlobal("HighBPM")
        
-       if lowBPM == highBPM then highBPM = nil end
+    if lowBPM == highBPM then highBPM = nil end
 
     local rateMod = string.gsub(GetRateMod(),'x','')
 
@@ -473,21 +473,17 @@ function DisplayScrollSpeed(pn)
     local rateMod = string.gsub(GetRateMod(),'x','')
     local speedMod = GetSpeedMod(pn)
     local lowBPM = GetGlobal("LowBPM")
-    local highBPM = GetGlobal("HighBPM")
-    local SpeedModType = GetSpeedModType(speedMod)
-       
+    local highBPM = GetGlobal("HighBPM")       
     if lowBPM == highBPM then highBPM = nil end 
        
-    speedMod = string.gsub(speedMod,'x','')
-    speedMod = string.gsub(speedMod,'c','')
-    speedMod = string.gsub(speedMod,'m','')
-
-    if SpeedModType == "c-mod" or SpeedModType == "m-mod" then return speedMod end
+    if speedMod.Type == "c-mod" or speedMod.Type == "m-mod" then return tostring((speedMod.Base + speedMod.Extra)*100) end
 
     if lowBPM == "Various" or lowBPM == "..." or lowBPM == nil then
         return "???"
     end
 
+    speedMod = speedMod.Base + speedMod.Extra;
+
     lowScrollBPM = math.floor(lowBPM * speedMod * rateMod)
 
     if highBPM then highScrollBPM = math.floor(highBPM *speedMod * rateMod) end
index d490c25..d7c70d7 100644 (file)
@@ -154,49 +154,19 @@ function GetSpeedMod(pn)
                                local CombinedSpeeds = BaseSpeeds[n] + string.gsub(ExtraSpeeds[m], 'x', '') --combines the speeds in to things like 4.50\r
 \r
                                --check x-mods\r
-                               if GAMESTATE:PlayerIsUsingModifier(pn, CombinedSpeeds .. 'x') then return CombinedSpeeds .. 'x' end\r
+                               if GAMESTATE:PlayerIsUsingModifier(pn, CombinedSpeeds .. 'x') then return { Name = CombinedSpeeds .. 'x', Base = BaseSpeeds[n], Extra = ExtraSpeeds[m], Type = 'x-mod' } end\r
        \r
                                --check c-mods\r
-                               if GAMESTATE:PlayerIsUsingModifier(pn, 'c' .. CombinedSpeeds*100) then return 'c' .. CombinedSpeeds*100 end\r
+                               if GAMESTATE:PlayerIsUsingModifier(pn, 'c' .. CombinedSpeeds*100) then return { Name = 'c' .. CombinedSpeeds*100 , Base = BaseSpeeds[n], Extra = ExtraSpeeds[m], Type = 'c-mod' }end\r
                                \r
                                --check m-mods (for some reason m0 is always applied so it has to be skipped)\r
-                               if GAMESTATE:PlayerIsUsingModifier(pn, 'm' .. CombinedSpeeds*100) and CombinedSpeeds ~= 0 then return 'm' .. CombinedSpeeds*100 end\r
+                               if GAMESTATE:PlayerIsUsingModifier(pn, 'm' .. CombinedSpeeds*100) and CombinedSpeeds ~= 0 then return { Name = 'm' .. CombinedSpeeds*100, Base = BaseSpeeds[n], Extra = ExtraSpeeds[m], Type = 'm-mod' } end\r
                        end\r
                end\r
        end\r
        \r
-       -- If we get here, chances are that m0 was applied.\r
-       return "m0"\r
-end\r
-\r
-function GetSpeedModBase(SpeedMod)     \r
-    local SpeedModType = GetSpeedModType(SpeedMod)\r
-\r
-    SpeedMod = string.gsub(SpeedMod, 'c', '')\r
-    SpeedMod = string.gsub(SpeedMod, 'm', '')\r
-    SpeedMod = string.gsub(SpeedMod, 'x', '')\r
-       \r
-    if SpeedModType == 'c-mod' or SpeedModType == 'm-mod' then SpeedMod = SpeedMod/100 end\r
-       \r
-    return tostring(math.floor(SpeedMod)) -- Consistency: all the others return a string due to concatenation or w/e\r
-end\r
-\r
-function GetSpeedModExtra(SpeedMod)\r
-    local SpeedModType = GetSpeedModType(SpeedMod)\r
-\r
-    SpeedMod = string.gsub(SpeedMod, 'c', '')\r
-    SpeedMod = string.gsub(SpeedMod, 'm', '')\r
-    SpeedMod = string.gsub(SpeedMod, 'x', '')\r
-       \r
-    if SpeedModType == 'c-mod' or SpeedModType == 'm-mod' then SpeedMod = SpeedMod/100 end\r
-\r
-    return '+' .. SpeedMod - math.floor(SpeedMod)\r
-end\r
-\r
-function GetSpeedModType(SpeedMod)\r
-    if string.find(SpeedMod, "x") ~= nil then return 'x-mod' end\r
-    if string.find(SpeedMod, "c") ~= nil then return 'c-mod' end\r
-    if string.find(SpeedMod, "m") ~= nil then return 'm-mod' end\r
+       -- If we get here, chances are that m0 was applied. TODO: Maybe put a check in to see that it was?\r
+       return { Name = 'm0', Base = "0", Extra = "0", Type = "m-mod" }\r
 end\r
 \r
 function SpeedMods(name)\r
@@ -212,49 +182,44 @@ function SpeedMods(name)
         -- default to the first item in the list\r
         list[1] = true\r
         local SpeedMod = GetSpeedMod(pn)\r
-        local ModBase = GetSpeedModBase(SpeedMod)\r
-        local ModExtra = GetSpeedModExtra(SpeedMod)\r
-        local ModType = GetSpeedModType(SpeedMod)\r
 \r
         -- now loop through everything else in the list and see if it is set to true\r
         for i=2, table.getn(modList) do\r
             if name == "Base" then\r
-                if modList[i] == ModBase then list[i] = true; list[1] = false else list[i] = false end\r
+                if modList[i] == SpeedMod.Base then list[i] = true; list[1] = false else list[i] = false end\r
             end\r
 \r
             if name == "Extra" then\r
-                if string.gsub(modList[i], 'x', '') == ModExtra then list[i] = true; list[1] = false else list[i] = false end\r
+                if string.gsub(modList[i], 'x', '') == SpeedMod.Extra then list[i] = true; list[1] = false else list[i] = false end\r
             end\r
 \r
             if name == "Type" then                             \r
-                if modList[i] == ModType then list[i] = true; list[1] = false else list[i] = false end\r
+                if modList[i] == SpeedMod.Type then list[i] = true; list[1] = false else list[i] = false end\r
             end\r
         end\r
     end\r
 \r
     local function Save(self, list, pn)\r
         local SpeedMod = GetSpeedMod(pn)\r
-        local ModBase = GetSpeedModBase(SpeedMod)\r
-        local ModExtra = GetSpeedModExtra(SpeedMod)\r
-        local ModType = GetSpeedModType(SpeedMod)\r
 \r
         for i = 1, table.getn(modList) do\r
             if list[i] then\r
-                if name == "Base" then ModBase = modList[i] end\r
-                if name == "Extra" then ModExtra = modList[i] end\r
-                if name == "Type" then ModType = modList[i] end\r
+                if name == "Base" then SpeedMod.Base = modList[i] end\r
+                if name == "Extra" then SpeedMod.Extra = modList[i] end\r
+                if name == "Type" then SpeedMod.Type = modList[i] end\r
             end\r
         end\r
                        \r
         if GetSpeedModRowType() ~= "pro" then\r
-            GAMESTATE:ApplyGameCommand('mod,' .. ModBase, pn+1)\r
+            GAMESTATE:ApplyGameCommand('mod,' .. SpeedMod.Base, pn+1)\r
             MESSAGEMAN:Broadcast('SpeedModChangedP' .. pn+1)\r
         else\r
-            local SpeedMod = ModBase + ModExtra\r
-               \r
-            if ModType == 'c-mod' then SpeedMod = 'c' .. SpeedMod*100 end\r
-            if ModType == 'm-mod' then SpeedMod = 'm' .. SpeedMod*100 end\r
-            if ModType == 'x-mod' then SpeedMod = SpeedMod .. 'x' end      \r
+            local SpeedModNumber = SpeedMod.Base + SpeedMod.Extra\r
+            local SpeedModToApply = "1x"\r
+\r
+            if SpeedMod.Type == 'c-mod' then SpeedModToApply = 'c' .. SpeedModNumber*100 end\r
+            if SpeedMod.Type == 'm-mod' then SpeedModToApply = 'm' .. SpeedModNumber*100 end\r
+            if SpeedMod.Type == 'x-mod' then SpeedModToApply = SpeedModNumber .. 'x' end      \r
 \r
             --[[ This is the most retarded thing. For some reason when you apply an M-Mod or an X-Mod you can\r
             get these weird situations where GAMESTATE:PlayerIsUsingModifier will tell you that there is an M and\r
@@ -264,7 +229,7 @@ function SpeedMods(name)
             will ever look ]]--\r
             if ModType == 'm-mod' then GAMESTATE:ApplyGameCommand('mod,9999x',pn+1) end\r
             if ModType == 'x-mod' then GAMESTATE:ApplyGameCommand('mod,m9999',pn+1) end\r
-            GAMESTATE:ApplyGameCommand('mod,'..SpeedMod,pn+1) --this is so annoying, the player number has to be 1 or 2 for ApplyGameCommand\r
+            GAMESTATE:ApplyGameCommand('mod,'..SpeedModToApply,pn+1) --this is so annoying, the player number has to be 1 or 2 for ApplyGameCommand\r
             MESSAGEMAN:Broadcast('SpeedModChangedP' .. pn+1)\r
         end\r
     end\r