wbunkey2244 Posted November 27, 2015 Share Posted November 27, 2015 (edited) Howdy All, I'm very new to modding and it is quickly becoming apparent that I will need to make an MCM, but I don't understand the very very basic concepts....For instance, I want to toggle a quest on or off that runs a script on the player, but how does the MCM toggle interact with the mod to actually do this? Edited November 27, 2015 by wbunkey2244 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 27, 2015 Share Posted November 27, 2015 In case you haven't found it, start here: https://github.com/schlangster/skyui/wiki/MCM-QuickstartMore advanced stuff can be found on the linked pages at the top right. To answer the question: MCM itself is just an interactive menu display, by itself it does nothing. You use the OnConfigClose event to set mod specific variables, run mod specific events, start/stop mod specific quests, etc... depending upon the value of the various MCM entry variables. Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted November 27, 2015 Share Posted November 27, 2015 Note about starting quests from MCM (This is what I've found from hands on and not from documentation).I've found in most cases, do not directly call start() on quests from any MCM event if you can help it.Start quest is a latent function and calling it directly from an MCM event has the potential to hang the MCM event until the quest starts and returns to the MCM event that called it ( this includes OnConfigClose event).Which in turn can cause weird and unpredictable MCM behavior for any mod that is registered with MCM.Some bad examples of calling myQuest.Start() in MCM.Toggle option to enable a quest from MCM and in the OnOptionSelected event having myQuest.Start()This is an absolute No No...Start() can not start the Quest while in a Menu, since your in MCM it means the quest can not start and now you have hung the OnOptionSelected event as it's waiting for the myQuest.Start() to return which it can't while the MCM menu is open.Other MCM controls on the page may become unresponsive and MCM may become very quirky until exited.OnConfigClose event and calling myQuest.Start() is a little better as the menu has closed, but still has the same problem as above..OnConfigClose event fires when the user exits your MCM menu, but the user may not exit the Tween menu all together and they may actually enter another MCM menu without actually closing all menus.If you have myQuest.Start() in the OnConfigClose event in your menu and the user hasn't fully exited all menus completely, then more then likely you have a hung OnConfigClose event.Which in turn will affect other MCM menus and cause weird behavior in other MCM menus until the user exits all menus.In most cases I found it better to place a quest Start handler function in another script and call the Handler function from MCM.In the handler function use RegisterForSingleUpdate(x.x).Handle the quest Start() in the OnUpdate() Event instead.In the OnUpdate() event you can do some brief checks like IsInMenuMode() and IsRunning()/IsStopped() etc..If the criteria to start the quest can't be met, then call for a single update again or handle it how you like...This way when you call the quest start Handler function from MCM events the handler function returns straight away to MCM event and you don't end up with a hung MCM event and glitchy MCM behavior. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 28, 2015 Share Posted November 28, 2015 Nice to know there is a workaround for situations like that... One of my already released mods needed to start a quest and/or do other stuff that was latent. As a solution, I put up a pop up when the player entered my menu instructing them that they had to fully exit the menus and return to the game after making their selections. Its not a popular mod so I'm not worried, but going forward I'll be sure to make use of this workaround. Might be good to put up a working example somewhere... Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted November 28, 2015 Share Posted November 28, 2015 That is also a partial solution.But the problem is if the quest is told to start and it hangs for what ever reason you still end up with a hung mcm event.There is no real absolute bullet proof solution when it comes to calling a quest to start.Instead of letting the user close the menu, force it closed yourself either by Input tap key tween or ui.invoke ...lolOf coarse put a info tip when pointing at the control in MCM stating that enabling this option will exit all menus and carry out the action.I found calling a handler function that registers for a single update in a non important quest script was really the better way for my use as it doesn't leave MCM menu with hanging events if the quest.start() for what ever reason hangs (may not even be menu open related).To many mods depend on MCM and I'd hate to be the one causing them all grief because of me doing something that has the potential to hang the whole MCM up... loli see people calling big loops with each iteration doing multiple function calls in their mcm script, that's another thing I always avoid (eg: sorting a container or inventory from MCM script, these types of things should be done outside of mcm).Do your non mcm loop functions in other scripts and always return the calling mcm event as quick as possible is the best practice for me anyway. Link to comment Share on other sites More sharing options...
Recommended Posts