Is there a Time & Date command in script (4 game Save & Load)?
by Leroy Frederick · in Torque Game Builder · 04/07/2007 (12:30 pm) · 13 replies
Hiya all,
Been looking around a bit and couldn't find a command to get the current time and date for the saving and loading of a game? Bit surprised that I haven't found anything, after all, surely most of the torque made games have such a feature? Has everyone had to edit engine code to have this feature? I have the source code, but Id seriously rather not mess with it if possibly, unless absolutely necessary!
Oh, one more thing, has a directory rename/delete function been added yet (it would make my profile system a lot cleaner if many profiles are created), last time I asked, I was told I would have to c++ to implement it or something similar.
Info/solution would be much appreciated in any case! Thanks in advance all and one! :0)

Been looking around a bit and couldn't find a command to get the current time and date for the saving and loading of a game? Bit surprised that I haven't found anything, after all, surely most of the torque made games have such a feature? Has everyone had to edit engine code to have this feature? I have the source code, but Id seriously rather not mess with it if possibly, unless absolutely necessary!
Oh, one more thing, has a directory rename/delete function been added yet (it would make my profile system a lot cleaner if many profiles are created), last time I asked, I was told I would have to c++ to implement it or something similar.
Info/solution would be much appreciated in any case! Thanks in advance all and one! :0)

#2
04/07/2007 (5:09 pm)
Thanks David, I'll check those out, any way of getting the date through script also?
#3
04/08/2007 (12:13 pm)
Leroy, the date is in the value returned ... it's just not in a "readable" format :)
#4
04/09/2007 (2:26 am)
Oh, understood, thanks David! :0)
#5
The thing that disturbs me is that the actual time and date is showed at the very start of the console log. So there would be a way to now them by "reading" the first console line (though I don't know how to do that in script) and then adding the sim time to the init time to have the actual time of the save.
04/13/2007 (1:36 pm)
For me, gerealtime() is returning me the time since the computer is running, not the actual date and time.The thing that disturbs me is that the actual time and date is showed at the very start of the console log. So there would be a way to now them by "reading" the first console line (though I don't know how to do that in script) and then adding the sim time to the init time to have the actual time of the save.
#6
04/13/2007 (1:52 pm)
Thanks for that Benjamin, I think I could read the data from the console file (guessing off the top of my head, although i'm not sure). Only other thing is, does the console file get created in the same or similar fashion when the game is packaged/released?
#7
04/13/2007 (1:54 pm)
Yep, it does ^^
#8
04/13/2007 (2:42 pm)
ConsoleFunction( getTimeStamp, const char* , 1, 1, "Get a timestamp YYYYMMDD_HH.MM.SS_ms"
"the milliseconds (ms) should be taken w/ a grain of salt.")
{
static char retBuf[128];
Platform::LocalTime lt;
Platform::getLocalTime(lt);
S32 ms = Platform::getRealMilliseconds() + 300;
ms = ms - ((ms / 1000) * 1000);
ms /= 10;
dSprintf(retBuf, sizeof(retBuf), "%4d%0.2d%0.2d_%0.2d.%0.2d.%0.2d_%0.2d",
lt.year + 1900,
lt.month + 1,
lt.monthday,
lt.hour,
lt.min,
lt.sec,
ms);
return( retBuf );
}
#9
I'm having a go at these right now! I'll update what I achieve (or don't) later! Thanks again guys!
04/14/2007 (2:43 am)
Thanks for the confirmation Benjamin :0) Thanks for the code example Orion! :0)I'm having a go at these right now! I'll update what I achieve (or don't) later! Thanks again guys!
#10
2. I keep getting a parse error with the code given Orion. (Is this intended for the source code? If so, where is it suppose to go?)
3. getRealTime and getSimTime don't make any sense to me as I have nothing to compare it to anyway? Isn't that what it's for
I have to say, I find this all a truly bizarre, even QBasic has functions for getting time and date (if I remember rightly), and Im pretty sure it's somewhat necessary for save/load systems among other things, so who's got the resource/function that is needed for this? I can't believe this is a original feature request because it seems like people generally aren't all that sure how to do it?
I'm just a little surprised that with all of torquescript's sophistication and power, it seems to be missing very simple, basic functions. I thought it was simply a case of the date/time command not been added in the help/documentation. It just shouldn't be this complicated and long just to get time and date.
Forgive me in advance if this reads a little aggressive/negative (not my intention) or I'm misunderstanding something here...
04/14/2007 (3:10 am)
1. I don't think it's possible to read the console.log as it's in constant use, you can't even copy the file.2. I keep getting a parse error with the code given Orion. (Is this intended for the source code? If so, where is it suppose to go?)
3. getRealTime and getSimTime don't make any sense to me as I have nothing to compare it to anyway? Isn't that what it's for
I have to say, I find this all a truly bizarre, even QBasic has functions for getting time and date (if I remember rightly), and Im pretty sure it's somewhat necessary for save/load systems among other things, so who's got the resource/function that is needed for this? I can't believe this is a original feature request because it seems like people generally aren't all that sure how to do it?
I'm just a little surprised that with all of torquescript's sophistication and power, it seems to be missing very simple, basic functions. I thought it was simply a case of the date/time command not been added in the help/documentation. It just shouldn't be this complicated and long just to get time and date.
Forgive me in advance if this reads a little aggressive/negative (not my intention) or I'm misunderstanding something here...
#11
and yr right, it's a bit of an outage that there isn't a getTimeOfDay function in stock torque script.
04/14/2007 (9:27 am)
The code example i gave is engine-side. that is, it's C++. i would put it in main.cc, right below getRealTime().and yr right, it's a bit of an outage that there isn't a getTimeOfDay function in stock torque script.
#12
Being a C++ novice, it's seems I have next to no chance of going through c++ code and correcting the problem :(
So thanks very much to all again and if you have any other thoughts/solutions, they will be more then welcomed! Now I'm trying to contemplate the prospect of trying to release a game with no date/time saved in the save/load system, oh boy! :-S
04/14/2007 (3:29 pm)
Thanks much Orion, it works a treat! :0) Only one problem, after successfully fixing the '#include "platform/platformAudio.hreal" error in the main.cc file, rebuilding the exe seems to of caused some problems with the file reading functions and has basically messed up my user profile reading system :0(Being a C++ novice, it's seems I have next to no chance of going through c++ code and correcting the problem :(
So thanks very much to all again and if you have any other thoughts/solutions, they will be more then welcomed! Now I'm trying to contemplate the prospect of trying to release a game with no date/time saved in the save/load system, oh boy! :-S
#13
eventually you'll probably want to recompile the engine for one reason or another,
but if it's fooling with behaviour of scripts i'd give it a pass for the time being.
04/14/2007 (6:41 pm)
Ai yai yai. yah, it sounds like it might be simplest to skip this part for now.eventually you'll probably want to recompile the engine for one reason or another,
but if it's fooling with behaviour of scripts i'd give it a pass for the time being.
Associate David Higgins
DPHCoders.com
as for the IO code, no clue...