After a module loads a .vsav file, is there a way for the module to determine the name of that .vsav file? This would be the same file name that is prepended to the header of the Chat Log Window.
My intention is to use it to discern when a Pre-defined setup file is loaded, thus starting a new game of the indicated scenario.
Cheers,
Jim Hunter.
No, but if I can persuade the developers that an old 3.8 PR of mine is harmless for 3.7, then you will be able to obtain what you’ve asked for in an upcoming release.
To try it out, page through the build pages until you find a set of files and then choose the one for your platform.
You should find the game file name in property ModuleGameFileName. According to documentation that I wrote months ago, the property holds the last file opened by the current player. Test this for yourself by trying to access the property from another player who has synchronised to the game online. Even if this is the case, the information can be shared if need be, via steps in a Startup GKC.
My change does not address how you distinguish between a game file opened as a PDS and one opened from outside the module. It should be possible through a further Vassal change to indicate the source of the file, if we need to go further. I find that this issue has been discussed in this thread. Perhaps we don’t need to go so far but I’m open to taking a look if the demand is there.
Not wishing to curtail the release of my change but I wonder if there’s an alternative already available to you if you only need to know whether or not your file is a new game/PDS versus an existing game.
I suggest that you take a look at the Startup GKC options, in particular “At Start of Every Fresh Game Only”
With this option, you can use actions via GKC or a GHK that execute only if it’s a new game (including a game starting from a PreDefined Setup).
A more general way to determine an initial game state - one that allows for external files - is to use to Global Property that flags whether or not a file is in an initial state. That’s more fiddly and prone to user error, so if you don’t need that ability then the StartupGKC “Fresh Game” option is the best way.
Thanks for your reply, Mark.
I already use the Startup GKC to detect the state of a new game. The part I am missing is how best to determine which scenario (currently implemented as a Pre-defined setup) is being played, in order to determine which rules should be enforced, etc.
I could encode that information into a hidden piece which is instantiated into each scenario, and which initializes the scenario information as a Global Property during game start, but that seems a little kludgy.
I’ll look into the new feature you pointed me to.
Cheers,
Jim Hunter.
1 Like