Announcement

Collapse
No announcement yet.

Urrghhh - that scripting problems again

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Urrghhh - that scripting problems again

    I'm trying to put a wu shader visualization in my skin by using

    SystemObject.getLeftVuMeter(); etc....

    now this is a problem:

    I don't know how to run my function constantly, because
    when I press Play button it runs only once, but I would want it
    to run constantly.
    Is there any way to code it? Maybe running it every 10 miliseconds?
    This is a code:


    System.onPlay(){
    wushader();
    }

    wu_shader(){
    int L, R;
    L = System.getLeftVuMeter();
    L = L/255 * 128;
    R = System.getRightVuMeter();
    R = R/255 * 128;
    WuImageL.resize(215,86,L,4);
    WuImageR.resize(215,100,R,4);
    }

  • #2
    use a timer with a very small delay and do:

    code:

    Global Timer vutimer;

    System.onScriptLoading()
    {
    vutimer = new Timer;
    vutimer.setDelay( 5 ); /* 5 is Milliseconds. Can be lowered */
    if ( System.getPlayItemString() != "" )
    {
    vutimer.start();
    }
    }

    System.onScriptUnloading()
    {
    delete vutimer;
    }

    System.onPlay()
    {
    vutimer.start();
    }

    vutimer.onTimer()
    {
    wu_shader();
    vutimer.start();
    }

    wu_shader()
    {
    int L, R;
    L = System.getLeftVuMeter();
    L = L/255 * 128;
    R = System.getRightVuMeter();
    R = R/255 * 128;
    WuImageL.resize(215,86,L,4);
    WuImageR.resize(215,100,R,4);
    }

    I'm sure my code is a little clumsy but i think it gets the job done.
    www.bluni.com
    Ben Folds Lyrics Database

    Comment


    • #3
      the getPlayItemString member function is used to see if anything is currently playing. The play sring is nothing when nothing is playing so if the string isn't nothing, then the timer should start because a song is already playing when the script was loaded.
      www.bluni.com
      Ben Folds Lyrics Database

      Comment


      • #4
        Thanks dude! I understand scripting, you don't have to explain it



        By the way, your script has some mistakes, but I managed to fix them.
        Now it works perfectly.
        And also I'm using a bit higher delay, 120 milliseconds,
        but in time between another function resizes layer slowly from one point to another if you understand what am I saying.
        This way it looks smoother

        Thanks for your help

        Comment


        • #5
          yea .. i hacked out that script in like 5 min so it probably sucked big time, but i'm glad you got the general gist of it.

          Hope the skin works out great.
          www.bluni.com
          Ben Folds Lyrics Database

          Comment


          • #6
            I don't know about skin working out great

            Also, one more question for everyone who knows scripting more than I do:


            Function abcd();

            abcd{
            Timer slow;
            slow = new Timer;
            slow.setDelay(10);

            slow.onTimer(){
            argument 1;
            argument 2;
            argument 3;
            // etc......
            }


            }



            Why the italic text isnt possible???
            When I try to compile it, it says syntax error and points at "{".
            Then I set this:


            slow.onTimer();

            So I have question. When I set that argument, is it working as a delay of 10 miliseconds (pauses script before continuing) or does nothing, and is it possible to call an extern Function from within other Function by using onTimer (or simply put some arguments in onTimer block).
            Thanx

            Comment


            • #7
              Function abcd();

              abcd() {
              Timer slow;
              slow = new Timer;
              slow.setDelay(10);
              [I]
              slow.onTimer(){
              argument 1;
              argument 2;
              argument 3;
              // etc......
              }

              Insert Red Text

              /*
              S0Be
              */
              And On that day, the Lords of the land said unto their Master Architect, "The temple you have made to the gods of Wasabi and Maki has brought us no great prosperity" and they sent out him into the lands.

              As he traveled to a far off land, he found he wasn't traveling alone, but that he had gained companions, and when they found their new land, they started work on a new temple, one that would be OPEN to all who wanted to worship.

              from The Book of Wasabi C 12 Vs 09 (pg 2003)

              Comment


              • #8
                brackets were mistake in question, not in real script

                I'm still searching for answer on my previous post

                Comment


                • #9
                  have you tried without arguments?

                  Comment


                  • #10
                    Originally posted by jakov.sosic
                    I don't know about skin working out great

                    Also, one more question for everyone who knows scripting more than I do:


                    Function abcd();

                    abcd{
                    Timer slow;
                    slow = new Timer;
                    slow.setDelay(10);

                    slow.onTimer(){
                    argument 1;
                    argument 2;
                    argument 3;
                    // etc......
                    }


                    }



                    Why the italic text isnt possible???
                    When I try to compile it, it says syntax error and points at "{".
                    Then I set this:


                    slow.onTimer();

                    So I have question. When I set that argument, is it working as a delay of 10 miliseconds (pauses script before continuing) or does nothing, and is it possible to call an extern Function from within other Function by using onTimer (or simply put some arguments in onTimer block).
                    Thanx
                    You can't put a function in a function, here is the right way to do it :

                    Global Timer slow; // <- make "slow" a global variable accessable by all functions/events

                    Function abcd();

                    abcd() {
                    slow = new Timer;
                    slow.setDelay(10);
                    } // <- close function abcd

                    slow.onTimer(){
                    argument 1;
                    argument 2;
                    argument 3;
                    // etc......
                    }

                    Francis.
                    Bluemars - Music For The Space Traveller

                    Comment


                    • #11
                      heh, I didn't even notice the discrepency in the braces... it's a monday...

                      /*
                      S0Be
                      */
                      And On that day, the Lords of the land said unto their Master Architect, "The temple you have made to the gods of Wasabi and Maki has brought us no great prosperity" and they sent out him into the lands.

                      As he traveled to a far off land, he found he wasn't traveling alone, but that he had gained companions, and when they found their new land, they started work on a new temple, one that would be OPEN to all who wanted to worship.

                      from The Book of Wasabi C 12 Vs 09 (pg 2003)

                      Comment


                      • #12
                        yea.. Francis is right. 'slow' is only used in the braces and nowhere else. Atleast thats how the compiler interperets it
                        www.bluni.com
                        Ben Folds Lyrics Database

                        Comment

                        Working...
                        X