playMaker

Author Topic: Add up an array of time strings like 2:32,3:14 etc? to get "total time"?  (Read 744 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • View Profile
    • My Video Game Projects Web Site
I am wondering what the best way to do this is. Is there a simple action for this?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6320
    • View Profile
    • jinxtergames
Re: Add up an array of time strings like 2:32,3:14 etc? to get "total time"?
« Reply #1 on: December 07, 2020, 04:48:51 AM »
Hi.
If not every frame then probably best to make an array loop.
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 657
    • View Profile
Re: Add up an array of time strings like 2:32,3:14 etc? to get "total time"?
« Reply #2 on: December 07, 2020, 09:01:11 AM »
It depends, if you're doing it once or if you're updating the array on the fly but you would most certainly need to use Array Get Next that plugs into a small loop to do the addition based on the last float gotten from the array.
Maybe there's a custom action on the ecosystem that adds all values of an array if they're floats (there would be an Error: Event in case another type is found). I guess this and a similar one for ints could be practical after all.

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • View Profile
    • My Video Game Projects Web Site
Re: Add up an array of time strings like 2:32,3:14 etc? to get "total time"?
« Reply #3 on: December 07, 2020, 09:32:54 AM »
is there a more efficient way then splitting the string by the :, then doing string to int, then adding up the seconds to 60 to get minutes?

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 657
    • View Profile
Re: Add up an array of time strings like 2:32,3:14 etc? to get "total time"?
« Reply #4 on: December 08, 2020, 05:08:23 AM »
If time values are given in the mm:ss format, then extracting the text's number before the : is the way to go unless someone wrote an action that specifically deconstructs string fields that specifically contain time indexes such as yours.

RAVEN001

  • Junior Playmaker
  • **
  • Posts: 66
  • BANNED
    • View Profile
Re: Add up an array of time strings like 2:32,3:14 etc? to get "total time"?
« Reply #5 on: January 22, 2021, 01:32:41 AM »
Any time i've needed to deal with time specifically i've made 3 ints, seconds, minutes, hours. once an int hit 60 it would add 1 to the next value (however in my game it represented a 9-5 job and things were sped up).
If what you want is to add values i only see the need to make an "int get difference" action, so when one of the ints hits 60, you add one to the next int and store the remainder as the current int.
ie X=60 (seconds), y=current time + z=added time, y+z=more than 60, store difference as a value. If this action spits out a value (on true?), then add 1 to the next value (minutes) but the addition would be a separate action.
The ":" is purely cosmetic.

This may be messy, inefficient or completely useless, but real time isn't measured in delta time and its the only way that made sense to me.

Perhaps even a portion of what i'm suggesting may lead you to a better solution.   
« Last Edit: January 22, 2021, 07:22:02 AM by RAVEN001 »
BANNED