How To Pass Objects Between Nodes On Same Object?

Discussion in 'Buildbox 3.0' started by Steddyman, Sep 8, 2018.

  1. LBPToo

    LBPToo Avid Boxer

    Joined:
    Nov 1, 2016
    Messages:
    233
    Likes Received:
    141
    Hi mxstudios, It does show errors on Windows, it's just broken on Mac.

    Good job, that functionality should be in BB3 by default.
     
  2. mxstudios

    mxstudios Boxer

    Joined:
    Aug 30, 2016
    Messages:
    51
    Likes Received:
    13
    Ah. Maybe I need to do some dev on the PC. Might speed it up for the scripting. Thx for letting me know that.
     
  3. LBPToo

    LBPToo Avid Boxer

    Joined:
    Nov 1, 2016
    Messages:
    233
    Likes Received:
    141
    I have BB on PC and Mac. I started using Mac with BB3 as I did with BB2 but the first version of BB3 wouldn't run on my Mac because of something to do with the graphics engine, so I switched to PC and it turned out it was lucky because of the error reporting. I'm sure it has saved me days of debugging having that available.
     
  4. Robin Miller

    Robin Miller Boxer

    Joined:
    May 3, 2020
    Messages:
    13
    Likes Received:
    1
    Hi Bill
    I'm new to both Buildbox and JS (unfortunately). I found it BB via fb ad and I have an idea for a puzzle game so thought I'd give it a try.
    Hopefully there's a way to do what I want natively but I can't find one, so Google brought me here!

    I have 2 objects ('Square 1' and 'Square 4')
    I'm trying to pass the colour of Sq4 to Sq1. (They will change over time)
    Trying to implement your code above I have (hoping it posts correctly!)

    Sq4 (Object), in a 'Set Color' Node that I have named 'Set Start Color'. This is the sending node:
    Code:
    function init(){
    
    }
    
    function update(dt){
    
    }
    
    var sq4colour
    
    function signal(name, value) {
    
    //Check the incoming signals
    
    if (name == 'Set' && value) {
    
    //get the node attributes
    
    let col = this.attribute('Color');
    
    
    //set the entity color
    
    this.entity().setColor(col.r, col.g, col.b, col.a);
    
    sq4colour = this.entity().color
    
    
    let comp = this.entity().component('Square 1.Set Color');
    
    comp.signal('send_sq4colour', sq4colour );
    
    
    //Emit signal to indicate the node finished
    
    this.emitSignal('Done', true);
    
    }
    
    }
    

    Sq1 (Object), in a 'Set Color' Node named 'Set Color'. This is the receiving node:

    Code:
    function init(){
    
    }
    
    function update(dt){
    
    }
    
    var colour_from_sq4
    
    function signal(name, value) {
    
    //Check the incoming signals
    
    if (name == 'send_sq4colour') {
    
    colour_from_sq4 = value
    
    //get the node attributes
    
    //let col = this.attribute('Color');
    
    //set the entity color
    
    this.entity().setColor(colour_from_sq4.r, colour_from_sq4.g, colour_from_sq4.b, colour_from_sq4.a);
    
    //Emit signal to indicate the node finished
    
    this.emitSignal('Done', true);
    
    }
    
    }
    
    I'm getting a compile(?) error:
    JS Error [asset: Square 4, component: Set Start Color, line: 0] - TypeError: comp is null

    Pls help!
    Thanks
    Robin
     

Share This Page