HISE Logo Forum
    • Categories
    • Register
    • Login

    Randomizer on 3 Grouped buttons, How?

    Scheduled Pinned Locked Moved Scripting
    97 Posts 4 Posters 4.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • NatanN
      Natan @d.healey
      last edited by

      @d-healey Haha :) Sir!!!

      NatanN 1 Reply Last reply Reply Quote 1
      • NatanN
        Natan @Natan
        last edited by

        @d-healey No Idea,can't do it by myself :)

        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @Natan
          last edited by d.healey

          @Natan Yes you can, one step at a time. You're not by yourself, I'm here :D

          Can you create an array?
          Can you create a button?
          Can you put a reference to the button into the array?

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          NatanN 1 Reply Last reply Reply Quote 1
          • NatanN
            Natan @d.healey
            last edited by

            @d-healey
            I'm still here:

            Content.makeFrontInterface(600, 500);
            
            const randomValue = Math.randInt(0, 3);
            Console.print(randomValue);
            
            
            const var Btns = [Content.getComponent("Button3"),
                              Content.getComponent("Button2"),
                              Content.getComponent("Button1")];
            
                              
                              
            inline function onRandITControl(component, value)
            {
                
            
            };
            
            Content.getComponent("RandIT").setControlCallback(onRandITControl);
            
            1 Reply Last reply Reply Quote 1
            • d.healeyD
              d.healey
              last edited by

              Perfect. Now move the randomValue inside the button's callback function, you'll need to use a local variable instead of a const.

              You can use the random value as the Btns array index to turn on one of the buttons.

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              NatanN 1 Reply Last reply Reply Quote 0
              • NatanN
                Natan @d.healey
                last edited by

                @d-healey is this correct?

                Content.makeFrontInterface(600, 500);
                
                const randomValue = Math.randInt(0, 3);
                Console.print(randomValue);
                
                
                const var Btns = [Content.getComponent("Button3"),
                                  Content.getComponent("Button2"),
                                  Content.getComponent("Button1")];
                
                                  
                
                inline function onRandITControl(component, value)
                {
                    local idx = buttons.indexOf(component);
                
                    
                };
                
                Content.getComponent("RandIT").setControlCallback(onRandITControl);
                
                
                
                d.healeyD 1 Reply Last reply Reply Quote 0
                • d.healeyD
                  d.healey @Natan
                  last edited by

                  @Natan Not even close :p

                  Move the randomValue stuff inside the button's callback. You'll need to use a local variable instead of a const. You can delete the Console.print() we don't need that now.

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  NatanN 1 Reply Last reply Reply Quote 0
                  • NatanN
                    Natan @d.healey
                    last edited by

                    @d-healey Lol

                    Content.makeFrontInterface(600, 500);
                    
                    
                    
                    
                    const var Btns = [Content.getComponent("Button3"),
                                      Content.getComponent("Button2"),
                                      Content.getComponent("Button1")];
                    
                                      
                    
                    inline function onRandITControl(component, value)
                    {
                    local randomValue = Math.randInt(0, 3);
                    Console.print(randomValue);    
                    
                    };
                    
                    Content.getComponent("RandIT").setControlCallback(onRandITControl);
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      d.healey
                      last edited by

                      Now we're getting somewhere!

                      We don't need Console.print() any more, that was just for testing the random value which we know works now.

                      Do you know how to turn a button on or off by changing its value?

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      NatanN 1 Reply Last reply Reply Quote 0
                      • NatanN
                        Natan @d.healey
                        last edited by

                        @d-healey Yeah, I Guess I'm So Close :)
                        Wait Sir

                        1 Reply Last reply Reply Quote 1
                        • NatanN
                          Natan
                          last edited by

                          @d-healey Haha, That Was A Real Challenge, And Yep This is it :)

                          Content.makeFrontInterface(600, 500);
                          
                          
                          const var Btns = [Content.getComponent("Button3"),
                                            Content.getComponent("Button2"),
                                            Content.getComponent("Button1")];
                          
                                            
                          inline function onRandITControl(component, value)
                          {
                          
                              local randomValue = Math.randInt(0, 3);
                              Console.print(randomValue);   
                          
                              if (value == 1)
                              {
                                 Btns[randomValue].setValue(1);
                              }      
                          };
                          
                          Content.getComponent("RandIT").setControlCallback(onRandITControl);
                          
                          1 Reply Last reply Reply Quote 1
                          • d.healeyD
                            d.healey
                            last edited by

                            Yeah looks like you got it! Well done!

                            Libre Wave - Freedom respecting instruments and effects
                            My Patreon - HISE tutorials
                            YouTube Channel - Public HISE tutorials

                            NatanN 1 Reply Last reply Reply Quote 1
                            • NatanN
                              Natan @d.healey
                              last edited by

                              @d-healey :) Haha Yessir :)
                              Thanks You Dear David, True Legend :)

                              d.healeyD 1 Reply Last reply Reply Quote 0
                              • d.healeyD
                                d.healey @Natan
                                last edited by

                                @Natan You did it, not me. I just nudged you :p

                                Libre Wave - Freedom respecting instruments and effects
                                My Patreon - HISE tutorials
                                YouTube Channel - Public HISE tutorials

                                NatanN DanHD 2 Replies Last reply Reply Quote 3
                                • NatanN
                                  Natan @d.healey
                                  last edited by

                                  @d-healey Thanks for the help, You're a great guy :)

                                  1 Reply Last reply Reply Quote 0
                                  • DanHD
                                    DanH @d.healey
                                    last edited by

                                    @d-healey Just trying this out. What if I wanted only one of the buttons to be on at a time? Like a radio group. I can get them to go on and off randomly, but not like a radio group...

                                    DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                    https://dhplugins.com/ | https://dcbreaks.com/
                                    London, UK

                                    d.healeyD 1 Reply Last reply Reply Quote 0
                                    • d.healeyD
                                      d.healey @DanH
                                      last edited by

                                      @DanH Check out my tabbed interfaces video.

                                      Libre Wave - Freedom respecting instruments and effects
                                      My Patreon - HISE tutorials
                                      YouTube Channel - Public HISE tutorials

                                      DanHD 2 Replies Last reply Reply Quote 0
                                      • DanHD
                                        DanH @d.healey
                                        last edited by

                                        @d-healey ah yes of course :) I'm already using it!

                                        DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                        https://dhplugins.com/ | https://dcbreaks.com/
                                        London, UK

                                        1 Reply Last reply Reply Quote 1
                                        • DanHD
                                          DanH @d.healey
                                          last edited by

                                          @d-healey Ok I am failing miserably at trying to combine these two scripts 😆

                                          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                          https://dhplugins.com/ | https://dcbreaks.com/
                                          London, UK

                                          d.healeyD 1 Reply Last reply Reply Quote 0
                                          • d.healeyD
                                            d.healey @DanH
                                            last edited by

                                            @DanH Post a minimal snippet

                                            Libre Wave - Freedom respecting instruments and effects
                                            My Patreon - HISE tutorials
                                            YouTube Channel - Public HISE tutorials

                                            DanHD 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            31

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.9k

                                            Posts