Rate per second

aliz94aliz94 Member, PRO Posts: 19

How do I calculate the rate per second of an attribute.

For example if I am earning 10 oranges/sec how do I display this?

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @aliz94 said:
    How do I calculate the rate per second of an attribute.

    An attribute does not have a 'rate'.

    @aliz94 said:
    For example if I am earning 10 oranges/sec how do I display this?

    I'd simply use "10"

    ?

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited June 2014

    Hi @aliz94 as @Socks says, an attribute doesn't have a rate, an attribute value can have, but I'm certain you meant to say that! :smile: so I'll revise your question:

    How do I display an integer (attribute) showing an average amount every second?

    I'm almost finished putting together a little test for you to show that; I'll post it soon.

    The basic principle is using integer attributes: game.PrevTotal, game.LatestTotal, game.AverageTotal and game.Count and use the following in your Average attribute in a Display Text behaviour to display every period of time required:

        Change Attribute game.Count to game.Count+1
           Change Attribute game.PrevTotal to ( game.PrevTotal + game.LatestTotal )
    Change Attribute game.AverageTotal to game.PrevTotal / game.Count
        Change Attribute LatestTotal to 0
    

    At least, I think that should work... off to finish the game file now... I'll be back...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited June 2014

    Here it is for you to check out... the only thing I've changed is the rate every 1 second seemed too quick in this user picking example, so I've made it every 4 seconds. Obviously you can change that to whatever you want.

    Edit again: if anyone's downloaded v1, 2 or 3, I've added changing Count to 0 in the Go button + deleted test actors, etc: here's latest version v4 now.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • aliz94aliz94 Member, PRO Posts: 19
    edited June 2014

    Wow thanks a lot, really appreciate it.

    @gyroscope said:
    Here it is for you to check out... the only thing I've changed is the rate every 1 second seemed too quick in this user picking example, so I've made it every 4 seconds. Obviously you can change that to whatever you want.

    Edit again: if anyone's downloaded v1, 2 or 3, I've added changing Count to 0 in the Go button + deleted test actors, etc: here's latest version v4 now.

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    You're welcome, and glad it helped.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • SocksSocks London, UK.Member Posts: 12,822

    @gyroscope said:
    You're welcome, and glad it helped.

    Lol, I'm glad you worked that one out, I was stumped !!

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited June 2014

    Ah, Cheers, @Socks :smile:

    I was on a roll this morning for some reason.... ham or cheese, I wasn't sure... :p

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @gyroscope said:
    Ah, Cheers, Socks :smile:

    I was on a roll this morning for some reason.... ham or cheese, I wasn't sure... :p

    Don't give up the day job :D

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    But...but...The Comedy Club beckons.....

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.