Url Node?

Discussion in 'Technical Discussion' started by itzonator, Aug 1, 2022.

  1. itzonator

    itzonator Serious Boxer

    Joined:
    Dec 18, 2017
    Messages:
    594
    Likes Received:
    228
    Hello,

    Does anyone know how to trigger an URL link when a certain object is tapped during gameplay, like for example:

    'Is Touched' node ->> goes to a URL we put in.

    I have the following setup:
    'Is Touched' node ->> 'Script' node with

    Code:
    function init(){
    
    }
    
    function start(){
    
    }
    
    function update(dt){
    
    }
    
    function signal(name, value, sender){
    
    if(name=="touch" && value)
    
    {
    
    log("Touch Confirmed");
    
    // HERE CUSTOM CODE IS NEEDED TO TRIGGER A LINK WHEN AN OBJECT IS TAPPED OR PRESSED DURING GAMEPLAY
    
    
    }
    
    }
    
    
    
    function requested(name, arg, sender){
    
    return this;
    
    }
    
    
    

    Anyone have an idea?

    The only closes solution in the API references is 'OnClick' --> https://www.buildbox.com/help/buildbox-3-api-reference/button/#onclick - but not sure if that can be utilized in this scenario.

    Thanks!
     
  2. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    @itzonator
    Hey there, I've done that in this demo, each large screen you can see in the game can be touched and will open an external link (on Rarible in this case).


    It's pretty simple to achieve.
    To make it work you need to create UI URL Buttons and move them in a hidden position, like this:
    url-buttons.png

    The setup is pretty simple:
    touchscreen-nodes.png

    The 'Open Link' script has an attribute (Button Name), there you input the name of the button that the script will then look for in the UI and activate.

    Here's the content of the script:
    Code:
    function signal(name, value, sender, source){
        if (value){
            let buttonName = this.attribute('Button Name');
            let button = this.ui().find(buttonName)[0];
            button.activate();
        }
    }
     
    Last edited: Aug 2, 2022
  3. iblicense principal

    iblicense principal Boxer

    Joined:
    Aug 26, 2020
    Messages:
    38
    Likes Received:
    11

    hello could you give an example BB . THANKS
     
  4. itzonator

    itzonator Serious Boxer

    Joined:
    Dec 18, 2017
    Messages:
    594
    Likes Received:
    228
    I found another way, to redirect to another UI and then using the URL button, it is an extra step, but works :)

    Thanks for your solution as well..

     
  5. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    Sure, here's a demo BBDOC.
     

    Attached Files:

Share This Page