.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Dominions 2: The Ascension Wars (http://forum.shrapnelgames.com/forumdisplay.php?f=55)
-   -   YAAS (Yet Another Autosave Script) (http://forum.shrapnelgames.com/showthread.php?t=17306)

alexti January 15th, 2004 04:58 AM

YAAS (Yet Another Autosave Script)
 
I remember reading few Posts asking about save feature, so I decided to share my script which auto-saves your game after every turn, and it also saves all your games once a day.

There're 2 files required that should go into your DomII installation directory:
save_script.awk:
</font><blockquote><font size="1" face="sans-serif, arial, verdana">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">BEGIN {
timestamp_file = &quot;Last-total-save-timestamp.txt&quot;;
t = systime();
stamp = strftime(&quot;%Y%m%d-%H%M%S&quot;,t);
stamp2 = strftime(&quot;%Y-%m-%d&quot;,t);
saveAll = 1;
if ((getline Last_stamp &lt; timestamp_file) &gt; 0)
{
if (stamp2 == Last_stamp)
saveAll = 0;
}
close(timestamp_file);

if (saveAll)
{
cmd = sprintf(&quot;zip -r save-all-%s * -i@save.lst&quot;,stamp);
print stamp2 &gt; timestamp_file;
}
else
cmd = sprintf(&quot;zip -r -t %s save-%s * -i@save.lst&quot;,Last_stamp,stamp);
system(cmd);
}</pre><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">save.lst:
</font><blockquote><font size="1" face="sans-serif, arial, verdana">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">*/ftherlnd
*/*.2h
*/*.trn</pre><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">Also, add --postexec "gawk -f save_script.awk" to your starting command. For example:
</font><blockquote><font size="1" face="sans-serif, arial, verdana">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">E:\gm\dominions2\dom2.exe --postexec &quot;gawk -f save_script.awk&quot;</pre><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">This will create timestamped zip file for every turn, and also once a day you'll get timestamped "save-all" file with all your games.

To restore the saved game just unzip appropriate save file.

The only current problem is that after the hosting Dom II window is going into the background and one has to alt-tab back into it. Not sure how to resolve it yet (even worse I'm not sure why it happens).

/Alex.

P.S. You need to have zip and gawk on your machine and path should include directories where they are.

Gandalf Parker January 15th, 2004 09:44 PM

Re: YAAS (Yet Another Autosave Script)
 
Nice script. Good AWK code. Thanks.

-- Have you ever noticed that the Klingons are all speaking unix?
"Grep ls awk chmod."
"Mknod ksh tar imap."
"Wall fsck yacc!" (that Last is obviously a curse of some sort)

[ January 15, 2004, 20:43: Message edited by: Gandalf Parker ]


All times are GMT -4. The time now is 11:32 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.