How Can I.. Spawn An Object Only If I Have Coins

Discussion in 'How Can I...?' started by Kendoh, Feb 23, 2020.

  1. Kendoh

    Kendoh Boxer

    Joined:
    Feb 21, 2020
    Messages:
    6
    Likes Received:
    1
    How do I check to see if I have coins before I spawn an object?

    Also, I have a timer adding coins every 30 seconds how do I only add coins if the player has less than 20?
    And, How do I simply display the timer on the screen?
     
  2. Kendoh

    Kendoh Boxer

    Joined:
    Feb 21, 2020
    Messages:
    6
    Likes Received:
    1
    I have my timer figured out but I still have no clue how to programmatically check if my player has coins. Can this be done?
     
  3. Hanomax

    Hanomax Avid Boxer

    Joined:
    Aug 24, 2018
    Messages:
    157
    Likes Received:
    85
    If you add this inside script node:
    Code:
    function signal(name, value){
        if(name == 'Enabled' && value && this.scene().currentCoins() < 20){
                this.emitSignal('spawn', true);
                }
    }
    
    And connect timer node (value can be 1) and connect it with script node, it checks every second coins count. If there are less than 20 coins, it sends out signal. Script input name is "Enabled" and output name is "spawn".
    And you can connect it with your 30 second timer node (disconnect from start node).
    Haven't tested this code, but it should work.
     
  4. Kendoh

    Kendoh Boxer

    Joined:
    Feb 21, 2020
    Messages:
    6
    Likes Received:
    1
    Thank you this will at least give me some direction even if the code doesn't work. I will check it out when I get home this evening.
     
  5. Kendoh

    Kendoh Boxer

    Joined:
    Feb 21, 2020
    Messages:
    6
    Likes Received:
    1
    Is the referenced in any documentation? Please link if it is. I wonder what else I can learn from that if it exists.
     
  6. Hanomax

    Hanomax Avid Boxer

    Joined:
    Aug 24, 2018
    Messages:
    157
    Likes Received:
    85
  7. stabilobre

    stabilobre Boxer

    Joined:
    Aug 28, 2019
    Messages:
    1
    Likes Received:
    0
    @Hanomax can you make some asset to help as all with this pls. I think this can solve my problem of coins going negative.
     

Share This Page