Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Saving Timer Informaiton

Author
Message
Westane
9
Years of Service
User Offline
Joined: 4th Dec 2014
Location:
Posted: 4th Dec 2014 18:53 Edited at: 4th Dec 2014 20:14
Hello all, apologies for the noob question.

I've decided to start work on a simulation game due to my masochistic tendencies, and have just about everything figured out save one bit of functionality.

The game will involve queuing up short work orders and I can easily use GetSeconds() command and a couple variables to pull it off. I don't necessarily need the accuracy of the Timer() function and I've heard it can be wonky cross platform.

My snag comes from when the player wants to save and quit the game with timers running. I think I may have just figured it out as I'm typing this post but since I'm at work napkin coding I may as well finish writing this for the sake of confirmation...

So if I make my work order arrays...


...Then I start working...


...And if I quit...


...And finally when we load...


In production I'd of course use For loops to check against all active work orders, but for the sake of example I just used 1.

So now that I think I answered my own question, I have to ask if I got the correct answer. Thanks!
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Dec 2014 21:01
I'm not sure that GetSeconds is the best command for this - I mean your saving the end time? - I think you'd be better off updating these arrays once per second, but store the seconds until it's complete - so you'd decrease the array until it hits 0 then the work order is ready. That way, when you save, it won't matter what the time is, because it can just continue to decrease the array.

Also, just a suggestion but it might be beneficial to use a typed array instead, like:

Type _work
Start Current Finish Resume
Endtype
Dim work[10] as _work

Then you'd use...

work[1].Start, work[1].Current etc instead of separate arrays.

This can really help with code readability.

I am the one who knocks...
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 4th Dec 2014 22:23
Agree with Van - make some types!

-- Jim - When is there going to be a release?
Westane
9
Years of Service
User Offline
Joined: 4th Dec 2014
Location:
Posted: 4th Dec 2014 22:46
I never thought about using Types to consolidate Arrays like that, that's fantastic, thank you!

What would be the best way to update values per second though? Something like:

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Dec 2014 09:58
Yeah, that's what I would do.

I am the one who knocks...

Login to post a reply

Server time is: 2024-11-25 13:36:25
Your offset time is: 2024-11-25 13:36:25