Advice for storing a time variable in choicescript

Hi!
This is an odd question, but a pretty useful one for me. I am looking to store and update a timecode variable, and am wondering if the only way to store it is indeed to convert this timecode to a simple number such as total seconds or similar. The timecodes are generated by transcription software (related to a real world interview) and I’m using some tests against this so am interested in updating a time variable related to where the reader is with these times.

Example timecodes are:
00:01:20.854 → 1 minute, 20 seconds, and .854 parts of a second (can probably round up or truncate)
01:45:15.55 → 1 hr, 45min, 15 seconds, 55 parts of a second. (again, can probably round or truncate unless i want to shift everything to milliseconds or something)

In something like excel, I think the timecode would be converted into say seconds or even frames, but just output in a timecode format. That is likely just fine for what I need. But I am wondering if any others have worked with timecode in a project for any reason and might have any ideas for other ways I should store these details.

The one additional context to include is the the experience of this choicescript game is to jump around the timeline within these interviews, but I want it possible to see the latest timecode in stats and there are a bunch of tests that tests for when certain times have been crossed.

Probably some will answer “why would you want to do this?” Well… that’s a future detail I’ll happily share in a few weeks. I’m more looking for advice for what makes sense – I’m guess switching things to whole numbers that are really easy to manage for the latest time variable, and processing these numbers to display in a timecode format for the stats version of these.

1 Like

If you need to do any sort of math on the time, I think storing it as a number of seconds (or similar) is the cleanest way to go. You could store it as a string, “hh:mm:ss”, and use the # operator to write a routine that parses out each individual component into temp arrays, but I don’t see the value personally. Just have a math function that convert both to and from the number.

3 Likes

That makes a lot of sense! thanks for the feedback — I think I’ll follow this approach!

Though I’m also realizing that if I only have a few markers to check that are easily parsed from a string var and the majority of my need is just displaying pretty timecode, I can follow the alternative route you suggest instead! I’ll assess how often I need to assess this and if there are a lot of time positions worth turning into triggers!

Still, the suggestion to just go to seconds for a numerical var sound like the way.

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.