Score Goes To Minus

Discussion in 'Buildbox 3.0' started by Leighton, Jan 8, 2019.

  1. Leighton

    Leighton Avid Boxer

    Joined:
    Jan 31, 2018
    Messages:
    373
    Likes Received:
    182
    I`m trying to stop my score/coins going to minus.

    I have a spawner that spawns 1 coin per click
    That amount is deducted from say 30 coins -1 = 29 coins until zero but,
    when it reaches zero it keeps going to -1, -2, -3 etc..
    I tried to add some code to "Add Coin Node" so when it reaches zero it stops until coins are back to 0+

    The Coin score is from UI label, do I need to call this?
    Thanks
     
  2. Leighton

    Leighton Avid Boxer

    Joined:
    Jan 31, 2018
    Messages:
    373
    Likes Received:
    182
    I checked the API and can't seem to locate the official variable for coins?
    All we have is addScoreCoin.
    So would Scorecoin be it?
     
  3. Scriv

    Scriv Boxer

    Joined:
    Oct 28, 2018
    Messages:
    50
    Likes Received:
    22
    Bump! I really need this too guys... Anyone? Any takers.... It's one line of code?
     
  4. weboha

    weboha Avid Boxer

    Joined:
    Aug 8, 2018
    Messages:
    239
    Likes Received:
    178
  5. weboha

    weboha Avid Boxer

    Joined:
    Aug 8, 2018
    Messages:
    239
    Likes Received:
    178
    sorry, you can not get coins numbers, only you can add.
     
  6. Leighton

    Leighton Avid Boxer

    Joined:
    Jan 31, 2018
    Messages:
    373
    Likes Received:
    182
    Would global vars work with player clicking until coins and reached zero and stop on zero?
     
  7. Leighton

    Leighton Avid Boxer

    Joined:
    Jan 31, 2018
    Messages:
    373
    Likes Received:
    182
    Get amount
    If coins <= 0
    Coins == 0
     
  8. weboha

    weboha Avid Boxer

    Joined:
    Aug 8, 2018
    Messages:
    239
    Likes Received:
    178
    yes but there is no code for get coins. you have add a global var, and when u add coin, add same number to global var.
    coin and global var will be always same number.
    then u can use this code:

    If Settings.coins <= 0
    Settings.coins == 0
     
    Leighton likes this.
  9. Leighton

    Leighton Avid Boxer

    Joined:
    Jan 31, 2018
    Messages:
    373
    Likes Received:
    182
    Code:
    var _dict;
    var _proto;
    var _debug;
    var _coin;
    var _settings.coins = 0;
    
    function init(){
        try
        {
            _coin = Settings.coins(0);
            _debug = this.attribute('Debug');
            _dict = {};
            _proto = Object.getPrototypeOf(this)
            _proto.setValue = function(name, value) {
                if(_debug) {
                    log("GlobalsManager:setValue - Name: " + name + ", Value: " + value);
                }
                _dict[name] = value;
            }
            _proto.getValue = function(name) {
                let ret = _dict[name];
                if(_debug) {
                    log("GlobalsManager:getValue - Name: " + name + ", Returning: " + ret);
                }
                return ret;
            }
            _proto.dump = function() {
                for(var key in _dict) {
                      var value = _dict[key];
                    log("GlobalsManager:debug - Name: " + key + ", Value: " + value);                
                }
            }
        }
        catch(e)
        {
            log("SetupError: " + e);
        }
    }
    
    function update(dt){
    
    }
    
    function signal(name, value){
            if(_settings.coins <= 0){
                _settings.coins == 0;
            }
    
    }
     
  10. Leighton

    Leighton Avid Boxer

    Joined:
    Jan 31, 2018
    Messages:
    373
    Likes Received:
    182
    Still not working
     

Share This Page