alexti
January 15th, 2004, 04:58 AM
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 = "Last-total-save-timestamp.txt";
t = systime();
stamp = strftime("%Y%m%d-%H%M%S",t);
stamp2 = strftime("%Y-%m-%d",t);
saveAll = 1;
if ((getline Last_stamp < timestamp_file) > 0)
{
if (stamp2 == Last_stamp)
saveAll = 0;
}
close(timestamp_file);
if (saveAll)
{
cmd = sprintf("zip -r save-all-%s * -i@save.lst",stamp);
print stamp2 > timestamp_file;
}
else
cmd = sprintf("zip -r -t %s save-%s * -i@save.lst",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 "gawk -f save_script.awk"</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.
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 = "Last-total-save-timestamp.txt";
t = systime();
stamp = strftime("%Y%m%d-%H%M%S",t);
stamp2 = strftime("%Y-%m-%d",t);
saveAll = 1;
if ((getline Last_stamp < timestamp_file) > 0)
{
if (stamp2 == Last_stamp)
saveAll = 0;
}
close(timestamp_file);
if (saveAll)
{
cmd = sprintf("zip -r save-all-%s * -i@save.lst",stamp);
print stamp2 > timestamp_file;
}
else
cmd = sprintf("zip -r -t %s save-%s * -i@save.lst",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 "gawk -f save_script.awk"</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.