Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Petra, AndrewAMD, Quad, VoroneTZ, 1 invisible), 488 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Military time variable #439760
04/08/14 19:57
04/08/14 19:57
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
Hi, I use military time format for my game but I need to display it on a panel in time format.

For example the variable is 1600 for 4 o clock and displays in a panel as 1600 but I need to separate the hour from the minute and put a colon in between like this 16:00. I managed to get the hour by dividing the variable by 100 example 'time_day / 100 = hour' but how can I get the minute?

Thanks

Re: Military time variable [Re: Truth] #439761
04/08/14 20:02
04/08/14 20:02
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
The variables are called sys_hours and sys_minutes.


Always learn from history, to be sure you make the same mistakes again...
Re: Military time variable [Re: Uhrwerk] #439762
04/08/14 20:08
04/08/14 20:08
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
Thanks for reply but I'm not using the system time. Im using my own in game time which is using the variable 'time_day'. is there a way to display half a variable? I.e for 1249 just '12' in one panel and just '49' in another?

Re: Military time variable [Re: Truth] #439763
04/08/14 20:29
04/08/14 20:29
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
use window for that

Last edited by Dico; 04/08/14 21:55.
Re: Military time variable [Re: Dico] #439765
04/08/14 21:12
04/08/14 21:12
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Code:
float time = 1652 / 100.0;

int hours = (int)time;
int minutes = (time - hours) * 100;



hours is 16, minutes is 52.
Also, you are doing time calculation and storage wrong. What you really want is a variable that accumulates time in the smallest unit that you want to store and then calculate the time of day from there.


Also, Dico, I like your way of opening doors with tanks. All kidding aside, how are you going to take care of things like kerning with that?


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Military time variable [Re: WretchedSid] #439767
04/08/14 21:51
04/08/14 21:51
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
JustSid : laugh

i'm not have much time to help in this forum , but from time to time i open forum page and see the news and all what i found is questions grin

Re: Military time variable [Re: Dico] #439768
04/08/14 22:04
04/08/14 22:04
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
Thanks for the replies I overcame the problem by using the time_day / 100
example time_day = 1652; hour = time_day / 10, 16.52 is the new variable and I display that on a panel and cover the decimal with another panel containing ':'



But JustSid this is the exact calculation I was looking for to give me the minutes! Thanks laugh

Last edited by Truth; 04/08/14 22:07.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1