[returns a previously saved actor]\r
- Name: the name of the actor to retrieve.\r
\r
-RegisterGlobalCallback( Name, fn )\r
+RegisterGlobalCallback( Name, Actor )\r
[sets up a function to be called when a global is registered]\r
- Name: the name of the global to apply the callback to\r
- - fn: the callback\r
+ - Actor: the Actor that the callback will be applied to\r
\r
The intended way to use this API is by calling RegisterGlobal from your theme's\r
metrics.ini. For example, to save away the song bpm to use later you would\r
Then we can set up callbacks to pull out the low and high BPMs like so:\r
\r
local function LowBPM( BPMDisplay )\r
- local pos = string.find(BPMDisplay, "-")\r
+ local pos = BPMDisplay:GetText()\r
+ pos = string.find(BPMDisplay, "-")\r
if pos ~= nil then return string.sub(BPMDisplay,1,pos-1) else return BPMDisplay end\r
end\r
\r
local function HighBPM( BPMDisplay )\r
- local pos = string.find(BPMDisplay, "-")\r
+ local pos = BPMDisplay:GetText()\r
+ pos = string.find(BPMDisplay, "-")\r
if pos ~= nil then return string.sub(BPMDisplay,pos+1) else return BPMDisplay end\r
end\r
\r
local CallbackTable = {}\r
\r
function RegisterGlobal( Name, Actor )\r
- GlobalsTable[Name] = Actor:GetText()\r
- \r
- if CallbackTable[Name] ~= nil then GlobalsTable[Name] = CallbackTable[Name](GlobalsTable[Name]) end\r
+ if CallbackTable[Name] ~= nil\r
+ then GlobalsTable[Name] = CallbackTable[Name](Actor)\r
+ else\r
+ GlobalsTable[Name] = Actor:GetText() \r
+ end\r
end\r
\r
function GetGlobal(Name)\r
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','')
function DisplaySongLength()
local RateMod = string.gsub(GetRateMod(), "x" ,"")
local ratio = 1/RateMod
+
local seconds = (GetGlobal('TotalTimeSeconds') + (GetGlobal('TotalTimeMinutes')*60))*ratio
return string.format("%.2d:%.2d", math.mod(seconds/60,60), math.mod(seconds,60))
--easter eggs
local function BlazeIt(Params)
- local spaces = string.rep(" ", string.len(DisplayScrollSpeed(Params.pn)))
+ local spaces = string.rep(" ", string.len(DisplayScrollSpeed(Params.pn)))
if DisplayScrollSpeed(Params.pn) == '420' then
Params.Actor:settext(spaces .. " Blaze It!")
end
local function NoScope(Params)
- local spaces = string.rep(" ", string.len(DisplayScrollSpeed(Params.pn)))
+ local spaces = string.rep(" ", string.len(DisplayScrollSpeed(Params.pn)))
if DisplayScrollSpeed(Params.pn) == '360' then
Params.Actor:settext(spaces .. " No Scope!")
--global variable callbacks
local function LowBPM( BPMDisplay )
+ BPMDisplay = BPMDisplay:GetText()
+
local pos = string.find(BPMDisplay, "-")
if pos ~= nil then return string.sub(BPMDisplay,1,pos-1) else return BPMDisplay end
end
local function HighBPM( BPMDisplay )
+ BPMDisplay = BPMDisplay:GetText()
+
local pos = string.find(BPMDisplay, "-")
if pos ~= nil then return string.sub(BPMDisplay,pos+1) else return BPMDisplay end
end
local function TotalTimeMinutes( TimeDisplay )
+ TimeDisplay = TimeDisplay:GetText()
+
local pos = string.find(TimeDisplay, ':')
return string.sub(TimeDisplay, 1, pos-1)
end
local function TotalTimeSeconds( TimeDisplay )
+ TimeDisplay = TimeDisplay:GetText()
+
local pos = string.find(TimeDisplay, ':')
return string.sub(TimeDisplay, pos+1)
end
RegisterGlobalCallback("HighBPM", HighBPM)
RegisterGlobalCallback("LowBPM", LowBPM)
RegisterGlobalCallback("TotalTimeMinutes", TotalTimeMinutes)
-RegisterGlobalCallback("TotalTimeSeconds", TotalTimeSeconds)
\ No newline at end of file
+RegisterGlobalCallback("TotalTimeSeconds", TotalTimeSeconds)
+
+--actor setters
+
+function SetFromDisplayScrollSpeed( Actor, pn )
+ Actor:settext(DisplayScrollSpeed(pn))
+
+ local function GetWidthCallback( ScrollSpeedDisplay )
+ return ScrollSpeedDisplay:GetWidth()
+ end
+
+ if not GetGlobal("ScrollSpeedDisplayWidth") then
+ RegisterGlobalCallback("ScrollSpeedDisplayWidth", GetWidthCallback)
+ end
+
+ RegisterGlobal("ScrollSpeedDisplayWidth", Actor)
+end