playMaker

Author Topic: Format String Question  (Read 966 times)

phannDOTde

  • Full Member
  • ***
  • Posts: 233
    • View Profile
    • Peter Hann .de
Format String Question
« on: November 14, 2015, 05:21:17 AM »
Hey there,

I got a general "Format" String question. How can I archive a format like HH:MM to build a descent timedisplay? What I'm doing right now is I got following parts

String: DAY | INT: 1 (number of days) | INT: 1 (hours) | String: ":" | INT: 5 (minutes)

The result is  "DAY 1  1:5" but I would like to get it shown as "DAY 1  01:05"

any advice?

Best
Peter

memetic arts

  • Full Member
  • ***
  • Posts: 140
    • View Profile
Re: Format String Question
« Reply #1 on: November 15, 2015, 04:19:07 AM »
If you're not going to leverage the built-in Get System Time action, then you'll probably have to use the Convert Int to String action and parse it all together as a string. And honestly, that might be easier to do in script.
« Last Edit: November 15, 2015, 04:26:14 AM by memetic arts »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2260
    • View Profile
    • jinxtergames
Re: Format String Question
« Reply #2 on: November 15, 2015, 03:37:18 PM »
Hi,
if i understand you right,
then you can do "convert int to string" and set format "00" for the hours and do the same for minutes.
Then use "build string"
Set string parts to 6 then add to each part
part 1 "DAY " (with a space)
part 2 day value
part 3 another space
part 4 hour string
part 5 ":"
part 6 minutes string

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Format String Question
« Reply #3 on: November 16, 2015, 05:50:57 AM »
Hi,

 I would use timeSpan custom actions and string format. They are on the Ecosystem.

"GetTimeSpaneBetweenDates"
"GetTimeSpanInfo"

and so you simply keep track of a start date and time, a current date and time and the spn between the two to then get time spane info out of it.

 I use it for a timer app I created a while ago, it works well.

Bye,

 Jean

memetic arts

  • Full Member
  • ***
  • Posts: 140
    • View Profile
Re: Format String Question
« Reply #4 on: November 16, 2015, 09:38:39 AM »
Ha, and I was just about to thank djaydino for the tip on the BuildString action, which looks super-useful -- didn't know that existed.  But these other actions look great too . . . thank you both!


phannDOTde

  • Full Member
  • ***
  • Posts: 233
    • View Profile
    • Peter Hann .de
Re: Format String Question
« Reply #5 on: November 17, 2015, 01:59:03 AM »
Hey thanks for your replies guys! :-)

@Jean - it's not to be used with real time/systemtime more of an ingame clock that can be accelerated while the player travels on a worldmap.

@djaydino Build string might work - gotta check this out - I thought there might be something simpler since I remember there are some definitions on formating strings (can't find the link to that atm) and {00:00} can work as a format definition if I only got one variable but it doesn't work in example with {0}{11:11} last I tried - maybe there is a limitation to the "Format String" Action there. Need to revisit that soon.

Greets
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Format String Question
« Reply #6 on: November 17, 2015, 05:47:17 AM »
Hi,

 however you want to control the start and end date in yourg ame will work with the solution of timeStamps. TimeStamps do not necessarly represent the current time, it can be anything.

Bye,

 Jean