Jump to content


Photo

measuring elapsed time between saving and loading


  • Please log in to reply
4 replies to this topic

#1 j4m1ef0rd

j4m1ef0rd

    GMC Member

  • GMC Member
  • 35 posts
  • Version:GM:Studio

Posted 09 April 2012 - 04:06 PM

i am currently working on a v-pet game, but i am a little bit stuck on working out the time that has passed between saving and loading. as i need to know this so it can effect the age of the pet.
i have tryed playing around with date_current_datetime() and date_compare_time(time1,time2) functions but i am having no luck.
i think the problem is that i don't fully understand the units/method of the date_time functions.

so could someone please post some gml that can detect the time passed in usable units or explain how i could do it.
all help would be much appreciated.
i think a copy of the game when released go's to whoever can help me out :)
  • 0

#2 Centauri

Centauri

    GMC Member

  • GMC Member
  • 116 posts

Posted 09 April 2012 - 04:17 PM

The function 'date_compare_time(time1,time2)' only returns whether time2 is greater than time1 (true) or less (false).

I think what you're looking is 'date_day_span(time1, time2)' which would give you the number of days between the two dates.
  • 0

#3 Rekulath

Rekulath

    GMC Member

  • GMC Member
  • 18 posts

Posted 09 April 2012 - 04:45 PM

i am currently working on a v-pet game, but i am a little bit stuck on working out the time that has passed between saving and loading. as i need to know this so it can effect the age of the pet.
i have tryed playing around with date_current_datetime() and date_compare_time(time1,time2) functions but i am having no luck.
i think the problem is that i don't fully understand the units/method of the date_time functions.

so could someone please post some gml that can detect the time passed in usable units or explain how i could do it.
all help would be much appreciated.
i think a copy of the game when released go's to whoever can help me out :)


I will chime in and say it may depend on what version of gamemaker you are using whether or not the date and time functions will return usable numbers. In GM:Studio currently for example, in both the windows and html5 compile you end up with the date/time value being inprecise and rounded, making it unable to return the amount of seconds or even minutes passed between 2 date/time values. I have been trying to work around this for some time and even submitted bug reports but to no avail, as my game also relies on a mechanic that detects how much time passes between a save/load. If anyone else has more insight into these functions it would be useful for me as well.
  • 0

#4 Centauri

Centauri

    GMC Member

  • GMC Member
  • 116 posts

Posted 09 April 2012 - 05:30 PM

I will chime in and say it may depend on what version of gamemaker you are using whether or not the date and time functions will return usable numbers. In GM:Studio currently for example, in both the windows and html5 compile you end up with the date/time value being inprecise and rounded, making it unable to return the amount of seconds or even minutes passed between 2 date/time values. I have been trying to work around this for some time and even submitted bug reports but to no avail, as my game also relies on a mechanic that detects how much time passes between a save/load. If anyone else has more insight into these functions it would be useful for me as well.


I tested the date functions in GM:HTML5 by saving the datetime to an INI file and then reading back in and comparing with the current datetime. This seemed to work fine.

But I just tested the same thing with GM-Studio and it doesn't work at all. I thought this might be due to rounding errors when I wrote the datetimes out to a file, and this does happen (as seen below). However, Studio doesn't even seem to be able to calculate the time difference correctly internally anyway as I also tried calculating the difference without the read from file stage.

BTW, when I thought the problem was with rounding errors when writing to file I used 'ini_write_real' and 'file_text_write_real' here to check rounding differences between GM:HTML5 and Studio... there doesn't seem to be any consistency:

HTML5 INI:  41008.7481593634
HTML5 TXT:  41008.757810
Studio INI: 41008.718432
Studio TXT: 41008.7155

Assuming the HTML INI entry is correct, as it produced correct time differences when read in, this does appear to be a bug in Studio!

Edited by Centauri, 09 April 2012 - 05:31 PM.

  • 0

#5 j4m1ef0rd

j4m1ef0rd

    GMC Member

  • GMC Member
  • 35 posts
  • Version:GM:Studio

Posted 10 April 2012 - 07:31 AM

thanks for the input, i will give the date_day_span() a shot and see what i can do.
btw i am using GM8.0 pro.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users