IsharaMeradin Posted September 22, 2016 Share Posted September 22, 2016 Basically, the title. I've seen some mods that do this but I'm do not know how to go about doing it for my own mod(s). I have both PapyrusUtil and FISS currently due to other mods that already require them. Not sure which one would be best. And definitely not sure of how or where to do the coding for it. Any ideas/suggestions or even code examples? Link to comment Share on other sites More sharing options...
palingard Posted September 23, 2016 Share Posted September 23, 2016 I have seen some code to reflect how to use FISS. It looks pretty straightforward and most all of the code sits in the ConfigScript. I don't have any code examples for you yet, as I haven't instrumented that portion in my mod. I can tell you where I have looked for guidance Take Notes - Journal for the Dragonborn (have to decompile the pex files)FollowerLivePackage Link to comment Share on other sites More sharing options...
cdcooley Posted September 23, 2016 Share Posted September 23, 2016 Most of the mods I've seen use FISS. And the easiest way to see how to use that would be to look at the MCM script for one of kryptopyr's mods. She has a very readable coding style even if she is using the original MCM script style instead of the new state model. Here are excerpts of the important bits from her Timing is Everything mod. She puts load and save buttons on the MCM page that calls these two functions. The BeginLoadPreset function looks more complicated because she's calling the OnOptionSliderAccept MCM function to trigger the right MCM state for each value she's reading in as she reads it. In some of the examples I haven't used here the values she stores are coming from global variables instead of script variables so you really should look at an entire working script but I think this demonstrates that it is relatively easy. Scriptname KRY_QD_MCMScript extends SKI_ConfigBase import FISSFactory ; ... Function BeginLoadPreset() if !ShowMessage("Are you sure? Loading this preset will overwrite the current settings.", true, "Load", "Cancel") return endif If !ShowMessage("Please do not leave the MCM menu until a new messagebox shows the load is complete.", true, "Begin Load", "Cancel") Return EndIf FISSInterface fiss = FISSFactory.getFISS() If (!fiss) Debug.MessageBox("FISS not installed. Loading disabled.") return EndIf fiss.beginLoad("TimingIsEverythingPresets.xml") OnOptionSliderAccept(OIDDA02, fiss.loadFloat("DA02MinLevel")) OnOptionSliderAccept(OIDDA04, fiss.loadFloat("DA04MinLevel")) ;... OnOptionMenuAccept(OIDDBCultAttackMenu, fiss.loadInt("DLC2QuestStartSelection_KRY")) ;... string loadResult = fiss.endLoad() ; check the result If (loadResult != "") ShowMessage("Error reading preset file.") Else ShowMessage("Preset has been loaded successfully!", false, "Okay") EndIf EndFunction Function BeginSavePreset() if !ShowMessage("Are you sure? This will overwrite the existing preset with your current settings.", true, "Save", "Cancel") return endif if !ShowMessage("Please do not leave the MCM menu until a new messagebox shows the save is complete.", true, "Begin Save", "Cancel") return endif FISSInterface fiss = FISSFactory.getFISS() If (!fiss) Debug.MessageBox("FISS not installed. Saving disabled.") return EndIf fiss.beginSave("TimingIsEverythingPresets.xml", "TimingIsEverything") fiss.saveFloat("DA02MinLevel", DA02Val) fiss.saveFloat("DA04MinLevel", DA04Val) ;... fiss.saveInt("DLC2QuestStartSelection_KRY", DBQuestSelection) ;... string saveResult = fiss.endSave() ; check the result If (saveResult != "") ShowMessage("Error saving preset file.") Else ShowMessage("Your settings has been successfully saved!", false, "Okay") EndIf EndFunction Link to comment Share on other sites More sharing options...
sevencardz Posted September 23, 2016 Share Posted September 23, 2016 Another option to consider is to use JaxonzConsolePlugin which adds functions to let you read custom INI variables: ScriptName IHOUtil hidden {Utility script for Immersive Horses.} import JaxonzConsolePlugin ; Returns the relative path to the INI file. String Function GetINIPath() global return ".\\data\\Immersive Horses.ini" EndFunction ; Loads the value for an integer variable from the given name of the variable from the INI file. ; Prints a warning to the log if the variable name is not found in the INI. int Function LoadINIInt(String varName) global String value = GetPrivateINIString(GetINIPath(), "General", varName) if value == "" Debug.Trace("[IHO Warning] variable General:" + varName + " not found at " + GetINIPath()) return -1 else return value as int endIf EndFunction Then, in Immersive Horses.ini: [General] ; Initial settings for various horse options: ; 0=no, 1=yes ProtectHorses=0 MountedSpellCasting=1 HorsesIgnoreCombat=0 LastHorseFastTravel=0 HorseWaitOnDismount=0 ; and so on... The advantage here is that it's rather simple to add all sorts of configuration options to your mod without having to script the in-game UI for each one, unless you really want that of course. Actually, you don't even need an MCM at all with this solution, so it's great for simple mods that just need a few config options. The disadvantages are that you're limited to using it as a way to initially configure your mod at start-up because Jaxonz utility only lets you read custom INI variables, not write them (currently). Also, the user has to manually edit the INI file with a text editor to 'save' his or her configuration. Basically, you have a custom read-only INI file for your mod. For example, I allow the user to edit the actor values of horse breeds in my mod. There are at least 8 breeds and each breed has 9 actor values that can be customized. I have no desire to build 72+ UI options over several pages in an MCM menu for the handful of users who'd ever actually bother to fool around with breed stats. However, the dozen or so general options and the various hotkey mappings are exposed via MCM as users are far more likely to change those during gameplay sessions. Of course, there's nothing stopping you from using a combination of INI loading and FISS if that suits your fancy. Link to comment Share on other sites More sharing options...
PeterMartyr Posted September 23, 2016 Share Posted September 23, 2016 If your Mod requires PapyrusUtil, I would use that over FISS, with it Json Files manual save & load, plus it auto-save & auto-load capabilities it better than FISS. (PU would be overkill if just for restoring MCM, in that case I would use FISS.) Just saying. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 23, 2016 Author Share Posted September 23, 2016 Ended up going with FISS as all I need is ability to store MCM settings for future use. Plus the code that cdcooley posted was helpful in figuring out proper usage. Link to comment Share on other sites More sharing options...
Recommended Posts