I managed to get the merchant container alias system to work. I have two quests, one that has the merchant container aliases, and another that stops and starts that first quest to restock all of the merchant containers. I also made a formlist with all of the items that my mod is adding to vendors. Once a day (based on GameDaysPassed) the monitoring quest uses RemoveItem to remove all of the items in the formlist from each of the merchant containers I made aliases for, then stops and restarts the other quest. The script looks like this:
Scriptname iiiMerchantTestQuest02Script extends Quest GlobalVariable Property GameDaysPassed autoGlobalVariable Property GameHour autoQuest Property testMerchantQuest autoReferenceAlias [] Property mouthful autoFormList Property goods autoint timeLastRestock = -1function StartMeUp() RegisterForSingleUpdate(1.0)endFunctionfunction OnUpdate() int gameDay = GameDaysPassed.GetValue() as int if !testMerchantQuest.IsRunning() timeLastRestock = gameDay testMerchantQuest.Start() elseIf gameDay > timeLastRestock restock() endIf RegisterForSingleUpdate(10.0)endFunctionfunction restock() int i = 0 while i < mouthful.Length ObjectReference or = mouthful[i].GetRef() if or != none or.RemoveItem(goods, 100) endIf i += 1 endWhile testMerchantQuest.Stop()endFunction
*Edit - Only issue I see is that apparently any object assigned to a quest alias persists in memory rather than unloading when you leave its cell. Is having a bunch of containers loaded into memory going to mean a big performance hit?
*Another edit - You can set up an empty alias that has your items added to the inventory, then use ForceRefTo to set the alias to a container object reference. Each time you do that, the items are added to the specified container, so you can just have a formlist of container references and step through it, removing the old inventory and adding the new. Oddly enough, if the alias starts out initialized to a container, the items won't be added until the quest is started. If you're adding via ForceRefTo though the items are added as soon as you set the alias, whether the quest is running or not.