FREE ACTION PLUGIN: Timer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ShadowUK
    No longer a forum member
    • Oct 2007
    • 1322

    FREE ACTION PLUGIN: Timer

    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 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:
    Code:
    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.
  • Worm
    Indigo Rose Customer
    • Jul 2002
    • 3971

    #2
    neat concept... Nice outa-the-box thinking :yes

    Comment

    • holtgrewe
      Indigo Rose Customer
      • Jul 2002
      • 779

      #3
      This has great potential; however after install:

      Error
      Startup, Line 790: Argument 1 must be type string.


      This was on the compile of an existing project before ever using the Timer function.

      Comment

      • ShadowUK
        No longer a forum member
        • Oct 2007
        • 1322

        #4
        Yeh, I seem to find this as well. I need to find out how to fix it first, I may have corrupted something in the core code.

        Edit:

        Nothing wrong with the code, But It might be the Actions file. In the mean time while I get this fixed please don't download it yet.
        Last edited by ShadowUK; 03-28-2008, 12:35 AM.

        Comment

        • ShadowUK
          No longer a forum member
          • Oct 2007
          • 1322

          #5
          Well, you can always use the code as normal. While I get working on this again.

          Comment

          • rexzooly
            No longer a forum member
            • Jul 2007
            • 1512

            #6
            Originally posted by ShadowUK View Post
            Well, you can always use the code as normal. While I get working on this again.
            i am keeping a eye this hope it becomes working soon so i can mirror it for you

            Comment

            • Worm
              Indigo Rose Customer
              • Jul 2002
              • 3971

              #7
              ShadowUK, this is only creating a branch within the current Page Timer, correct? If you have a "timer function" that is costly in time, the functions below them will be delayed that much longer, correct?

              Comment

              • ShadowUK
                No longer a forum member
                • Oct 2007
                • 1322

                #8
                It's an alternative to Application.Sleep, And I think I messed up in the XML, I'll be recoding this again.

                Comment

                Working...
                X