Description

A handy utility script for addon developers using MCM. Simple-to-configure storage for options in the players savefile.

Preview
[1.5.1 / MCM 1.3] MCM Savefile Storage
Post comment Comments
ravenascendant
ravenascendant - - 1,104 comments

"You may distribute this together with your addon, as long as you keep the script header intact."

I'm tempted to do just that when i update to fix the collections bug :)

Reply Good karma Bad karma+2 votes
Diphenhydramine-HCl Author
Diphenhydramine-HCl - - 257 comments

Sure, sounds great! Speaking of collections: This script can't handle them -- I might update it to do that when I find time. But since I haven't seen anyone else use that feature yet I doubt too many people will have a problem.

Also, I've been using your fix (j instead of i) locally and haven't experienced a single bug. It also didn't make any problems when I was adding a menu without collection in-between my collection menus. Apart from that I didn't do any testing, just normal usage.

Reply Good karma+1 vote
ravenascendant
ravenascendant - - 1,104 comments

If you implement support for arbitrary path length then it would be dph_mcm_save_storage.register_module("collection/example_example")

this would also lead in to support for specifying individual options that a moddev would like saved to the save rather than all or nothing.

Reply Good karma Bad karma+1 vote
Diphenhydramine-HCl Author
Diphenhydramine-HCl - - 257 comments

You're right, that's way more elegant and simple. I've updated the script.

Reply Good karma+2 votes
ravenascendant
ravenascendant - - 1,104 comments

You now have a credit in MCM. I did alias the function into mcm for clarity/brevity sake, but ppl that are calling it directly will have no problems as I did not edit your script in any way.

Reply Good karma Bad karma+1 vote
Diphenhydramine-HCl Author
Diphenhydramine-HCl - - 257 comments

Perfect, thanks for the credit.

Reply Good karma+1 vote
Ishmaeel
Ishmaeel - - 282 comments

Will it break savegame compatibility?

Reply Good karma Bad karma+1 vote
Diphenhydramine-HCl Author
Diphenhydramine-HCl - - 257 comments

No, when the script loads a modules state, it will check whether an entry in the mdata table exists for it, and skip it if that isn't the case (resulting in unchanged MCM options -- the same they were before loading the savegame). When it saves a modules state it will also do a check for nil, and initialize the appropiate entry in the mdata table the first time it's run for a given savegame.

You can safely remove the script and still load savegames with MCM options in it, it'll just be dead data. You can also remove the data from a savegame, and that'll only result in losing the stored MCM options.

EDIT:
The relevant code for both checks is at lines 76 and 91 if you want to take a look yourself.

Reply Good karma+2 votes
ravenascendant
ravenascendant - - 1,104 comments

Nope it uses the Marshal library to store information in the .coc portion of your save file. Abandoned data there is never read out and very unlikely to break any thing.

Reply Good karma Bad karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account:

Tags

[1.5.1 / MCM 1.3] MCM Savefile Storage has not been tagged yet.