Hi there, amazing mod idea, really think this is a much more comprehensive save system than vanilla or even taro's multiple saves.
I came here to say that the implementation has some issues that could cause compatibility issues with other mods (and maybe even vanilla, it's hard to say), and I think some these should at least be documented and the rest remedied.
The mod modifies world_state.nut in the following ways:
Adds 2 (imo really badly named) properties to the m table (asn and osn). I think this could easily be fixed by doing something like
Wraps the following functions without returning their return values. This should never be done and you should always be returning the value of the function you're wrapping: instead of just calling 'startCombatFunc()' at the end of your wrapper, you should be doing 'return startCombatFunc()'. THIS CAN AND WILL CAUSE ISSUES FOR NO REASON. This currently affects the following functions
function startCombat( _pos ) function saveCampaign ( _campaignFileName, _campaignLabel = null ) function exitGame() function onCombatFinished()
Completely overwrites the following functions, some of which can be relatively easily avoided.
function autosave() // this one is avoidable imo, do some of the if statements yourself and match the case you wanna handle, let the original function handle the rest function showTownScreen() // this one and the one below are obviously a lot more complicated to not overwrite, though possible with some hackery. I'd understand if you wanna keep these as overwrites but this should definitely be documented as changes to these functions in vanilla or legends would require and update from this mod. function showCampScreen() [Legends only]
Finally some miscellaneous notes THAT ARE ALSO IMPORTANT.
Your mod version number shouldn't actually be working and I believe is a bug in squirrel. 1.0.1 is simply parsed as 1.0 and the final .1 is thrown away. If you wanna use semantic versioning you should be using MSU and passing "1.0.1", if you're not planning to do then then simply remove the .1 and version with 1.1->1.2 etc
The properties you add to the m table aren't serialized, even though they really should be, this means that your counter restarts from 1 every time you reload the save, which isn't great imo. The fix for this isn't super trivial while preserving save compatibility so I'd just mark this as a TODO for when MSU 1.2 releases (at which point it will be very simple and I'll try to update this post)
I think the other issues are more important. I also noticed you should switch from mods_hookNewObject to mod_hookExactClass as it is more performant and reliable. Once MSU 1.2.0 releases I'll write up how you can hook showTownScreen and showCampScreen as well as how to fix the issue with your fields not getting serialized.
From the screenshot, it looks like it autosaves on other timing such as leaving town, and name the savefiles according to save timing, guess I will give it a try.
Tried it out, it autosaves at combat start, combat end, exit town and another autosave file just called autosave (I wonder what the timing is?) also make (Legend) tag on saves with Legend mod.
11 comments
However in later game, I have this issue.
I am running Legends 16.4.3 with MSU 1.2.7 and PTR 2.1.27.
Please help update this great mod
Screenshot
I came here to say that the implementation has some issues that could cause compatibility issues with other mods (and maybe even vanilla, it's hard to say), and I think some these should at least be documented and the rest remedied.
The mod modifies world_state.nut in the following ways:
o.m.EnhancedAutosave <- {
WellNamedProperty1 = 0,
WellNamedProperty2 = 0
};
function startCombat( _pos )
function saveCampaign ( _campaignFileName, _campaignLabel = null )
function exitGame()
function onCombatFinished()
function autosave() // this one is avoidable imo, do some of the if statements yourself and match the case you wanna handle, let the original function handle the rest
function showTownScreen() // this one and the one below are obviously a lot more complicated to not overwrite, though possible with some hackery. I'd understand if you wanna keep these as overwrites but this should definitely be documented as changes to these functions in vanilla or legends would require and update from this mod.
function showCampScreen() [Legends only]
Finally some miscellaneous notes THAT ARE ALSO IMPORTANT.