+--[[\r
+Simple SpeedMods API for 3.95/OpenITG, version 1.0\r
+Licensed under Creative Commons Attribution-Share Alike 3.0 Unported\r
+(http://creativecommons.org/licenses/by-sa/3.0/)\r
+\r
+Globally callable functions to set up multi-line speed mods and access the\r
+currently applied speed modifier.\r
+\r
+Written by Cameron Ball for OpenITG (http://www.boxorroxors.net/)\r
+All I ask is that you keep this notice intact and don't redistribute in bytecode.\r
+--]]\r
+\r
+\r
+-- This is purely for convenience\r
+local ProfileTable\r
+\r
+-- Without this check, when StepMania starts it will report a lua runtime error as PROFILEMAN apparently doesn't exist yet.\r
+if PROFILEMAN ~= nil then\r
+ ProfileTable = PROFILEMAN:GetMachineProfile():GetSaved()\r
+end\r
+\r
+ -- Valid speed mod row type names.\r
+local Names = { "Basic", "Advanced", "Pro" }\r
+\r
+function SpeedModTypeRow()\r
+ local type = GetSpeedModRowType()\r
+\r
+ local function Load(self, list, pn)\r
+ -- what we're doing here is checking what we got from profileman against the valid names.\r
+ for i=1,3 do\r
+ if type == string.lower(Names[i]) then list[i] = true return end\r
+ end\r
+\r
+ -- if nothing matched then just default to pro\r
+ list[3] = true\r
+ end\r
+\r
+ local function Save(self, list, pn)\r
+ -- go through each item in the list and save the first one that is set to true\r
+ for i=1,3 do\r
+ if list[i] then\r
+ ProfileTable.SpeedModType = string.lower(Names[i])\r
+ PROFILEMAN:SaveMachineProfile()\r
+ return\r
+ end\r
+ end\r
+ end\r
+\r
+ local Params = { Name = "SpeedModType" }\r
+\r
+ return CreateOptionRow( Params, Names, Load, Save )\r
+end\r
+\r
+function GetSpeedModRowType()\r
+ local type = ProfileTable.SpeedModType\r
+\r
+ -- as soon as we find a valid name, return it.\r
+ for i=1,3 do\r
+ if type == string.lower(Names[i]) then return type end\r
+ end\r
+\r
+ -- no pref, default to the first name in the list.\r
+ return string.lower(Names[1])\r
+end\r
+\r
function GetRateMods()\r
return { "1.0x", "1.1x", "1.2x", "1.3x", "1.4x", "1.5x", "1.6x", "1.7x", "2.0x"}\r
end\r
+++ /dev/null
--- This is purely for convenience
-local ProfileTable
-
--- Without this check, when StepMania starts it will report a lua runtime error as PROFILEMAN apparently doesn't exist yet.
-if PROFILEMAN ~= nil then
- ProfileTable = PROFILEMAN:GetMachineProfile():GetSaved()
-end
-
- -- Valid speed mod row type names.
-local Names = { "Basic", "Advanced", "Pro" }
-
-function SpeedModTypeRow()
- local type = GetSpeedModRowType()
-
- local function Load(self, list, pn)
- -- what we're doing here is checking what we got from profileman against the valid names.
- for i=1,3 do
- if type == string.lower(Names[i]) then list[i] = true return end
- end
-
- -- if nothing matched then just default to pro
- list[3] = true
- end
-
- local function Save(self, list, pn)
- -- go through each item in the list and save the first one that is set to true
- for i=1,3 do
- if list[i] then
- ProfileTable.SpeedModType = string.lower(Names[i])
- PROFILEMAN:SaveMachineProfile()
- return
- end
- end
- end
-
- local Params = { Name = "SpeedModType" }
-
- return CreateOptionRow( Params, Names, Load, Save )
-end
-
-function GetSpeedModRowType()
- local type = ProfileTable.SpeedModType
-
- -- as soon as we find a valid name, return it.
- for i=1,3 do
- if type == string.lower(Names[i]) then return type end
- end
-
- -- no pref, default to the first name in the list.
- return string.lower(Names[1])
-end
\ No newline at end of file