Modulus Division Problem

This forum is meant for posting anything related to Adventure Maker that doesn't fit in the other forums.Please post technical questions in the Technical Support Forum!

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Modulus Division Problem

Postby Deadconcept » Sat Mar 22, 2008 6:26 pm

I have created a timer for the game that counts how many seconds a player has played the game for its crude but it seems to work well. The problem I am having is that I want to change the format for when the game is finished. As so far the counter is in seconds but when the game finishes I have a screen that says Time Taken : [I want to put how many hours minutes etc it took them]
But for some reason I can't seem to get it to work at all.

Here is the code and I shall try and explain how it works using the example of 9024 seconds which is 2 hours 30 minutes and 24 seconds

Dim Temp
Dim Temp2

Temp = (Counter/3600) Mod 1 // Gets the mod division of how many hours it has done so it would 0.5066......
Hours = (Counter/3600) - Temp // Then take 0.50666... from the result which should be 2.
Temp2 = Temp * 3600// Then times 0.50666... by 3600 to get 1824
Temp = (Temp2/60) Mod 1// get mod division of 1824 which is 0.4
Minutes = (Temp2/60) - Temp// taking 0.4 from division which would be 30.4 -0.4 to get 30
Seconds = Temp * 60// then 0.4 times 60 to get 24

When i try this the modular division doesnt seem to work . Any help would be really good.
Deadconcept
New Member
 
Posts: 2
Joined: Sat Mar 22, 2008 6:19 pm

Postby GM-Support » Sat Mar 22, 2008 6:42 pm

Hi Deadconcept,

Welcome to the forums.

The following code should do the job:
Code: Select all
Hours = int(Counter / (60 * 60))
Minutes = int(Counter / 60) - (Hours * 60)
Seconds = int(Counter) - (Hours * 60 * 60) - (Minutes * 60)


Of course it can be simplified as follows:
Code: Select all
Hours = int(Counter / 3600)
Minutes = int(Counter / 60) - Hours * 60
Seconds = Counter - Hours * 3600 - Minutes * 60


GM-Support
GM-Support
Forum Admin and Games Page admin
 
Posts: 2221
Joined: Thu Jun 05, 2003 7:52 pm

Postby Lyberodoggy » Sat Mar 22, 2008 7:14 pm

Nice GM! Thanks for this one, it's a good way to show the time in general in games and can definitely help with puzzle creation
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Deadconcept » Sun Mar 23, 2008 7:10 pm

Thanks very much this completely sorted out my problem!
Deadconcept
New Member
 
Posts: 2
Joined: Sat Mar 22, 2008 6:19 pm


Return to Adventure Maker General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron