ShadowUK
03-27-2008, 03:52 PM
Timer Action Plugin
by ShadowUK
You'll need to go to your AutoPlay Media Studio folder and navigate to Data/Actions then put this file (http://www.flameounch.com/ActionPlugins/_at_Timer.xml) in that folder.
Now you've installed the Actions, it's time to install the functions!
Go to: AutoPlay Media Studio/Data/Includes and open _notification_messages.lua
Append at the bottom the following:
Timer = {}
Timer.OldTimerCode = Application.GetPageScript(this, "On Timer")
function Timer.Create(Name, Delay, Repeats, Function)
if (type(Function) == "function") then
error("string expected, got function! ("..assert(tostring(Function))..")");
elseif (type(Function) == "number") then
error("string expected, got number! ("..assert(tostring(Function))..")");
elseif (type(Function) == "table") then
error("string expected, got table! ("..assert(tostring(Function))..")");
elseif (type(Function) == "nil") then
error("attept to local global callback function (a nil value)");
end
function DoThink()
if (Occurrences == Repeats) then
Page.StopTimer()
Occurrences = nil
end
end
if (Repeats ~= 0) then
Occurrences = 0
Application.SetPageScript(this, "On Timer", Timer.OldTimerCode.."\r\n"..Function.."\r\nOccurrences = Occurrences + 1\r\nDoThink()");
Page.StartTimer(Delay * 1000)
elseif (Repeats == 0) then
Application.SetPageScript(this, "On Timer", Timer.OldTimerCode.."\r\n"..Function);
Page.StartTimer(Delay * 1000)
end
end
function Timer.Simple(Delay, Function)
if (type(Function) == "function") then
error("string expected, got function! ("..assert(tostring(Function))..")");
elseif (type(Function) == "number") then
error("string expected, got number! ("..assert(tostring(Function))..")");
elseif (type(Function) == "table") then
error("string expected, got table! ("..assert(tostring(Function))..")");
elseif (type(Function) == "nil") then
error("attept to local global callback function (a nil value)");
end
Application.SetPageScript(this, "On Timer", Timer.OldTimerCode.."\r\n"..Function.."\r\nPage.StopTimer()\r\nApplication.SetPageScript( Application.GetCurrentPage(), \"On Timer\", \"\")")
Page.StartTimer(Delay / 1000)
end
Save the file and off you go! Plugin installed!
Later down the line, I should consider creating an automatic plugin installer if I can't be bothered to use the real plugin method.
by ShadowUK
You'll need to go to your AutoPlay Media Studio folder and navigate to Data/Actions then put this file (http://www.flameounch.com/ActionPlugins/_at_Timer.xml) in that folder.
Now you've installed the Actions, it's time to install the functions!
Go to: AutoPlay Media Studio/Data/Includes and open _notification_messages.lua
Append at the bottom the following:
Timer = {}
Timer.OldTimerCode = Application.GetPageScript(this, "On Timer")
function Timer.Create(Name, Delay, Repeats, Function)
if (type(Function) == "function") then
error("string expected, got function! ("..assert(tostring(Function))..")");
elseif (type(Function) == "number") then
error("string expected, got number! ("..assert(tostring(Function))..")");
elseif (type(Function) == "table") then
error("string expected, got table! ("..assert(tostring(Function))..")");
elseif (type(Function) == "nil") then
error("attept to local global callback function (a nil value)");
end
function DoThink()
if (Occurrences == Repeats) then
Page.StopTimer()
Occurrences = nil
end
end
if (Repeats ~= 0) then
Occurrences = 0
Application.SetPageScript(this, "On Timer", Timer.OldTimerCode.."\r\n"..Function.."\r\nOccurrences = Occurrences + 1\r\nDoThink()");
Page.StartTimer(Delay * 1000)
elseif (Repeats == 0) then
Application.SetPageScript(this, "On Timer", Timer.OldTimerCode.."\r\n"..Function);
Page.StartTimer(Delay * 1000)
end
end
function Timer.Simple(Delay, Function)
if (type(Function) == "function") then
error("string expected, got function! ("..assert(tostring(Function))..")");
elseif (type(Function) == "number") then
error("string expected, got number! ("..assert(tostring(Function))..")");
elseif (type(Function) == "table") then
error("string expected, got table! ("..assert(tostring(Function))..")");
elseif (type(Function) == "nil") then
error("attept to local global callback function (a nil value)");
end
Application.SetPageScript(this, "On Timer", Timer.OldTimerCode.."\r\n"..Function.."\r\nPage.StopTimer()\r\nApplication.SetPageScript( Application.GetCurrentPage(), \"On Timer\", \"\")")
Page.StartTimer(Delay / 1000)
end
Save the file and off you go! Plugin installed!
Later down the line, I should consider creating an automatic plugin installer if I can't be bothered to use the real plugin method.