New Free Node: Real-world Elapsed Time Counter To Create Daily Gift Prizes/rewards And More

Discussion in 'BBNodes' started by Ivan Perfetti, May 23, 2020.

  1. Ivan Perfetti

    Ivan Perfetti Boxer

    Joined:
    Sep 9, 2018
    Messages:
    75
    Likes Received:
    81
    Hi all, here's a little gift to the Buildbox community, hope you'll enjoy it! :)
    I've been creating this node recently to implement in game gifts/rewards based on time elapsed in real-world in the next update of my new game for iOS: Space Runner 2600 (check it out here).
    @Sean Buildbox It would be great to have something similar integrated in Buildbox :)
    This might be useful to create rewards the player can obtain only once every hour or every day or whichever time interval you wish.
    Example: you want to have a prize to be available once every day to tempt players to open the game more frequently, you can do it with this node.
    This node can manage as many counters/events as you wish, just use the Counter ID attribute to assign a number to the event and that's it!

    A screenshot showing the node connected to a logger script.
    upload_2020-5-23_19-30-54.png

    Any question, comment/criticism (constructive possibly :D) is always appreciated, thank you!

    VERBOSITY ALERT: following is a more detailed explaination of what this node does and how, don't be scared about the length of this post, I have a tendency to become verbose sometimes, you don't need to read it all, just grab the asset, put it in your game and test it with various settings and the attached logger to see how it works.

    If you want more details there you go:
    This node can be used to keep track of real-world time elapsed between events and can be set to work in four different modes:
    basic counter, resetting counter, triggering counter, resetting triggering counter.
    It can be useful in various situations like when you wish to create hourly or daily gift rewards for players (I find it very convenient to put it inside UIs for this purpose) or have an in-game object to only pop every hour and so on.

    This node makes use of JavaScript Date object and Buildbox global Settings to keep track of time elapsed between events.

    IMPORTANT:
    This node creates a setting called Settings.elapsedTimeCounters, make sure there isn't another Setting with this name inside your game.
    Please also note that this node has been created in BB 3.2.1 so you will need this version of Buildbox to use it.

    Here's a quick description of every possible node behavior:

    - BASIC COUNTER (Default): 'Trigger event after' set to -1 (disabled) and 'Reset after event' unchecked.
    This is the default behavior, every time the node gets 'Enabled' it will just emit the signal 'Elapsed Time' and pass as value the elapsed time in seconds since the first recorded event with this Counter ID.
    The first time it gets enabled it will emit 0 as a value while in subsequent calls it will emit an alwaysi increasingtime in seconds.
    *** EXAMPLE ***
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 0
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 2.454
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 55.985
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 3688.012
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 25040.551

    This is useful if you just want something to keep track of elapsed time since this
    event was recorded for the first time.
    The node has a convenient 'Reset' input, just pass it a true value to reset the counter to 0.

    - RESETTING COUNTER: 'Trigger event after' set to -1 (disabled) and 'Reset after event' checked ✅.
    Same as the basic counter but each time the node gets enabled its timer will be reset.
    *** EXAMPLE ***
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 0
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 83.410
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 12.051
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 9850.112
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 482.908

    This is useful to keep track of elapsed time between the latest event and the previous one.
    The 'Reset' input is pretty much useless in this mode since the node is reset every time it gets enabled.

    - TRIGGERING COUNTER: 'Trigger event after' set >= 0
    Same as the basic counter plus when the elapsed time is greater than or equal to the value specified in the
    'Trigger Event After' attribute then the node will emit the signal 'Trigger' and pass true as value.
    In such a case the counter gets reset as well.
    *** EXAMPLE ***
    - 'Trigger event after' set to 86400 ( = 1 day)
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 0
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 82.255
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 58704.477
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 120508.704 | Trigger: TRUE
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 482.908


    - RESETTING TRIGGERING COUNTER: 'Trigger event after' set >= 0
    Same as the resetting counter plus when the elapsed time is greater than or equal to the value specified in the
    'Trigger Event After' attribute then the node will emit the signal 'Trigger' and pass true as value.
    In such a case the counter gets reset as well.
    *** EXAMPLE ***
    - 'Trigger event after' set to 86400 ( = 1 day)
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 0
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 48014.215
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 18704.479
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 120508.704 | Trigger: TRUE
    Signal IN >> Enabled: TRUE - Signal OUT >> Elapsed Time: 482.908


    Here's an extended node description/documentation, I've added this to the node itself as a comment so you don't really need this as a reference:

    upload_2020-5-23_19-56-15.png
     

    Attached Files:

    Last edited: May 25, 2020
  2. Robdd

    Robdd Boxer

    Joined:
    May 17, 2020
    Messages:
    12
    Likes Received:
    1
    Is it just me, or can I not go onto the zip file you attached?
     
  3. Robdd

    Robdd Boxer

    Joined:
    May 17, 2020
    Messages:
    12
    Likes Received:
    1
    I have finally put the node onto my mind map, how do I add an action after it triggers? I have tried but it doesn't work
     
  4. Robdd

    Robdd Boxer

    Joined:
    May 17, 2020
    Messages:
    12
    Likes Received:
    1
    I don't get how you reset the time after the user clicks the button
     
  5. Ivan Perfetti

    Ivan Perfetti Boxer

    Joined:
    Sep 9, 2018
    Messages:
    75
    Likes Received:
    81
    @Robdd Hi there, here's a demo bbdoc which shows how to connect and setup the counters, hopefully it will make things a little more understandable. Also, I've fixed a bug which caused errors when using more than a counter.
    In the zip file there are both a demo bbdoc and an updated bbasset file.
     

    Attached Files:

    Dyllin Aleluia likes this.
  6. Robdd

    Robdd Boxer

    Joined:
    May 17, 2020
    Messages:
    12
    Likes Received:
    1
    thx
     
  7. SpawnP

    SpawnP Boxer

    Joined:
    May 24, 2020
    Messages:
    6
    Likes Received:
    2
    @Ivan Perfetti could you update this node to latest buildbox version i.e. 3.3.1 or 3.2.3
     
  8. Ivan Perfetti

    Ivan Perfetti Boxer

    Joined:
    Sep 9, 2018
    Messages:
    75
    Likes Received:
    81
    Hi @SpawnP , sure, I'll check it out next week. What problems have you found?
     
  9. Ivan Perfetti

    Ivan Perfetti Boxer

    Joined:
    Sep 9, 2018
    Messages:
    75
    Likes Received:
    81
    @SpawnP Hi, I've tested it on BB 3.3.1 and it works fine in the preview, haven't tested yet on device but should work fine as well.
    I've fixed a minor problem in the UI and saved with BB 3.3.1, here's the bbdoc file.
     

    Attached Files:

Share This Page