IsharaMeradin Posted April 28, 2020 Share Posted April 28, 2020 Int function GetVersion() return 2 ; Default version endFunction Event OnVersionUpdate(int version) If version > 1 OnConfigInit() EndIf EndEvent Define the value in the GetVersion() function and that value will affect what happens in the OnVersionUpdate event. The above is a very simple example that will force an update whenever the version value is greater than 1. This is what I used in my Inventory Management System mod as I built it. I rolled the value back before actual release as users would be running it for the first time. More in depth explanation and examples can be found here: https://github.com/schlangster/skyui/wiki/MCM-Advanced-Features#Versioning Link to comment Share on other sites More sharing options...
dylbill Posted April 28, 2020 Share Posted April 28, 2020 That's good to know about versioning. Does running OnConfigInit again make new pages show up in a save where the MCM is already there? I noticed that when I add pages directly in the Creation Kit, the new ones don't show up if the mod was already active. To get around this, I make a version global variable. I set it at 1 in the CK for initial release. Then if I need to update it, I set it higher in the CK and use a script on a new quest to stop, then start the MCM quest, which makes the new pages show up. Scriptname MyUpdateScript Extends Quest Quest Property MyMcmQuest Auto GlobalVariable Property MyModVersion Auto Event OnInit() Utility.Wait(1) If MyModVersion.GetValue() < 2 ;this will be less than 2 if the mod was already installed MyMcmQuest.Stop() Utility.Wait(1) MyMcmQuest.Start() MyModVersion.SetValue(2) Endif Utility.Wait(1) Self.Stop() EndEvent If running OnConfigInit again works though, I may have to switch to that in the future. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 28, 2020 Share Posted April 28, 2020 It should work. I don't recall however as it has been a while since I actually created a MCM script or had need to add additional pages. Feel free to test it out and report back. Link to comment Share on other sites More sharing options...
dylbill Posted April 29, 2020 Share Posted April 29, 2020 Ok so i did some testing. If you set the pages string array in the CK, as I tend to do, new pages won't show up when updating. If however, you set your pages in the script's OnConfigInit event, new pages do show up when using the MCM's internal versioning. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 29, 2020 Share Posted April 29, 2020 That makes sense as the property value gets baked and cannot be updated without stopping and re-starting the quest, but values declared at runtime can get updated with a forced re-run of the OnConfigInit event. Link to comment Share on other sites More sharing options...
LagiaDOS Posted April 29, 2020 Author Share Posted April 29, 2020 Int function GetVersion() return 2 ; Default version endFunction Event OnVersionUpdate(int version) If version > 1 OnConfigInit() EndIf EndEvent Define the value in the GetVersion() function and that value will affect what happens in the OnVersionUpdate event. The above is a very simple example that will force an update whenever the version value is greater than 1. This is what I used in my Inventory Management System mod as I built it. I rolled the value back before actual release as users would be running it for the first time. More in depth explanation and examples can be found here: https://github.com/schlangster/skyui/wiki/MCM-Advanced-Features#Versioning Hi, sorry for answering late, I went to sleep, it was late at night. I've edited my code to now look like this Int function GetVersion() return 2 ; Default version endFunction Event OnVersionUpdate(int version) If version > 1 OnConfigInit() Pages = new string[2] Pages[0] = "Towns" Pages[1] = "Settlements" ;Pages[2] = "Skyrim" EndIf EndEvent I've put this instead of Event OnConfigInit() Pages = new string[2] Pages[0] = "Towns" Pages[1] = "Settlements" ;Pages[2] = "Skyrim" EndEvent It still doesn't update, I guess I've put that code in the wrong place. Link to comment Share on other sites More sharing options...
dylbill Posted April 29, 2020 Share Posted April 29, 2020 Hello, instead you can just put: Event OnConfigInit() Pages = new string[2] Pages[0] = "Towns" Pages[1] = "Settlements" ;Pages[2] = "Skyrim" EndEvent Int function GetVersion() return 2 ; Default version endFunction Event OnVersionUpdate(int version) If version > 1 OnConfigInit() Endif EndEventWhenever you add a page, and the mod has already been active in a save, you need to increase the version number in the get version function. I would only do this if you are releasing new versions to the public though. If you are simply testing or building the mod I would just load the same or previous saves where the mod hasn't been active yet. Link to comment Share on other sites More sharing options...
Recommended Posts