Kapteyn Posted October 4, 2017 Share Posted October 4, 2017 (edited) I dunno then, I haven't tried manipulating objects directly via the MCM - I use it to change global variables and then another script will reference them. Maybe that's what you need to do - maybe put a script on the object itself, which I guess would be the chest... and in the OnLoad() event you reference the global variable. If the global is on, skooma is good... if the global is off then it removes the skooma. That's because one is a command you type into the console whilst in game (the top) and the other is the papyrus function call (the bottom). Ah, I see. Good to know. :smile: Oh, OnConfigInit is an integral part of the MCM, I really don't think it'll do much without it. It's actually laid out properly I think, apart from those two things I mentioned everything looks in order. Also, SB... Bool KitVal = False Just a quirk... but bools are always false until you set it as true. https://www.creationkit.com/index.php?title=Default_Value_Reference Edited October 4, 2017 by Kapteyn Link to comment Share on other sites More sharing options...
Kapteyn Posted October 4, 2017 Share Posted October 4, 2017 (edited) Try this... ScriptName SB_MCMScript Extends SKI_ConfigBase Actor Property Risaad Auto LeveledItem Property SB_SkoomaSetPartB Auto MiscObject Property SB_SkoomaSet Auto GlobalVariable Property SB_SkoomaSetGlobal Auto ObjectReference Property CaravanAChestREF Auto Bool KitVal Int iKit Event OnConfigInit() Pages = new string[2] Pages[0] = "Settings" Pages[1] = "Skooma Types" EndEvent Event OnPageReset(string page) If page == "Settings" SetCursorFillMode(TOP_TO_BOTTOM) AddHeaderOption("My Header") AddEmptyOption() ikit = AddToggleOption("Caravans have Skooma Kit", KitVal) ElseIf page == "Skooma Types" ; To Do EndIf EndEvent Event OnOptionSelect(int option) If option == iKit If SB_SkoomaSetGlobal.GetValueInt() SB_SkoomaSetGlobal.SetValue(0) CaravanAChestREF.RemoveItem(SB_Skoomaset,10) Else SB_SkoomaSetGlobal.SetValue(1) EndIf EndIf EndEvent Event OnOptionHighlight(Int option) If option == iKit SetInfoText("This is an infotip") EndIf EndEvent Edited October 4, 2017 by Kapteyn Link to comment Share on other sites More sharing options...
foamyesque Posted October 4, 2017 Share Posted October 4, 2017 Oh, OnConfigInit is an integral part of the MCM, I really don't think it'll do much without it. It's actually laid out properly I think, apart from those two things I mentioned everything looks in order. It's an event that's listed in the API, but you don't need to put anything in it -- or even declare it in your script -- because it exists in the script you extend. Link to comment Share on other sites More sharing options...
Kapteyn Posted October 5, 2017 Share Posted October 5, 2017 I've looked at a few MCM source scripts, they all use OnConfigInit() to define the pages. I'm not saying it's absolutely necessary, but it appears to be standard practice. Link to comment Share on other sites More sharing options...
foamyesque Posted October 5, 2017 Share Posted October 5, 2017 I've looked at a few MCM source scripts, they all use OnConfigInit() to define the pages. I'm not saying it's absolutely necessary, but it appears to be standard practice. Hm. I was setting them directly in the properties.If I have some time tonight I'll compile SevenBlue's script and test it, see if I can figure out where it's hanging and why. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 5, 2017 Share Posted October 5, 2017 FYI - Either method is fine for establishing the page names for the Page array. Property methodPro - easy to add new page namesCon - ESP has to be edited for every translation (if any) At runtime during OnConfigInit eventPro - can use token method to pull correct text string from translation files allow for translations (if any) that do not need to edit the ESPCon - requires using an event that isn't always necessary (tho in some cases it would be used anyway) along with all the additional coding needed to make it happen. Additionally, Kapteyn's latest script suggestion for this particular MCM looks to be correct and appears that it wouldn't cause the issue that SevenBlue had where it failed to appear. Link to comment Share on other sites More sharing options...
SevenBlue Posted October 5, 2017 Author Share Posted October 5, 2017 Strangely I'm still encountering the issue when using Kapteyn's script, also it seems that the item is being added to the inventory of the merchants before the global is activated. So it seems I'll have to go back to adding and removing the item from leveledlistB in order to make it appear and disappear. Link to comment Share on other sites More sharing options...
Kapteyn Posted October 5, 2017 Share Posted October 5, 2017 All you're doing currently is removing the items when the button is pressed - nothing in the MCM script adds those items, it's in the levelled list. If you're trying to do this without waiting for the items to refresh normally like trader inventories usually do, a good way to do it is as I already said - attach a script to the container and use the OnLoad() function to add or remove items from it so that it happens whenever you encounter the trader. Whether or not you base it on the global setting alone is up to you, or you could even do it so that the guy only has skooma at certain times of the day or night. Link to comment Share on other sites More sharing options...
foamyesque Posted October 5, 2017 Share Posted October 5, 2017 I was worried the global method wouldn't work, but you were saying that it did... But I'm not out of tricks yet. scriptname SB_SkoomaCycler extends ReferenceAlias FormList Property SB_Skooma Auto Event OnInit() RegisterForSingleUpdateGameTime(48) EndEvent Event OnUpdateGameTime() RegisterForSingleUpdateGameTime(48) RemoveSkooma() AddSkooma() EndEvent Function AddSkooma() ObjectReference myRef = GetRef() Clear() ForceRefTo(myRef) EndFunction Function RemoveSkooma() GetRef().RemoveItem(SB_Skooma, 10000) EndFunction Put this script on an alias that contains the chest (or chests) you want to have your stuff. That alias should also have a leveled list in the inventory tab that has your desired stuff, what you're currently inserting into the caravan chest formlists. A clear/forcerefto combination will add the stuff in the inventory tab of a quest alias to whatever the alias was forced to, and, criticially, it will recalculate the leveled list when it does so, so you can set your globals, clear any existing inventory, then cycle the alias, and it'll get zero'd out as desired. Stuff added to a chest through this method will not be cleared away with generic merchant chest resets (as e.g. items added with script AddItems would be), nor will it go away when the alias is cleared, hence the chained OnUpdateGameTime() calls to remove and readd stuff. This method can also be made to work if you're using vanilla items, but it becomes significantly more complicated. However, you've said your items are newly created, so it shouldn't be necessary to elaborate. Link to comment Share on other sites More sharing options...
SevenBlue Posted October 8, 2017 Author Share Posted October 8, 2017 Sorry, had work the past few days. I followed the instructions yet am still coming across the same result. The MCM menu is freezing and the item is appearing in the merchant's inventory despite the global starting set at 0. Not sure where I messed up. Link to comment Share on other sites More sharing options...
Recommended Posts