MartyrKomplx Posted January 5, 2024 Share Posted January 5, 2024 (edited) The basic idea is: When you craft 3 x Dirty Water into 1 x Purified Water, I want the script to add to inventory 2 x Empty Bottles. I've found a pretty similar idea elsewhere on this forum, but the thread is over four years old, and it didn't have the resulting copy/paste code I was hoping for. If anyone can help me with this, I'd definitely be grateful. This is what I have been able to piece together so far from that thread, but it's not working. It's my very first time trying to script anything, and it's really the only thing I want to script (so far). Kind of hampering my enjoying of survival mode a bit, because it gets harder to find empty bottles. Every 1 bottle of purified water I craft/drink, that's 3 bottles gone. I guess I smash two bottles to make it, and smash the last bottle on the ground like Thor in the Diner. New ESP // New FormList with WaterPurified and BottleEmpty02 // New Quest with Start Game Enabled // New Quest Alias with Unique Actor: Player // New Script Scriptname BottlesBackMKS extends ReferenceAlias FormList Property BottlesBackList Auto Const Mandatory Potion Property WaterPurified Auto Const Mandatory MiscObject Property BottleEmpty02 Auto Const Mandatory Event OnAliasInit() RegisterForMenuOpenCloseEvent("CookingMenu") EndEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) If (abOpening == TRUE) Self.AddInventoryEventFilter(BottlesBackList) ElseIf (abOpening == FALSE) Self.RemoveInventoryEventFilter(BottlesBackList) Endif EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If (akBaseItem == WaterPurified) Game.GetPlayer().AddItem(BottleEmpty02, 1, true) Endif EndEvent Pieced together from this thread https://forums.nexusmods.com/topic/7590877-help-item-added-after-crafting-script/ I've tried to adapt it the best I could, but idunno. It compiles just fine, but it doesn't seem to do anything. Edited January 5, 2024 by MartyrKomplx Link to comment Share on other sites More sharing options...
Fantafaust Posted January 6, 2024 Share Posted January 6, 2024 Are you sure the alias is filling, and the quest is started? Ensure the player alias is marked optional or it could stop the quest from starting. Link to comment Share on other sites More sharing options...
MartyrKomplx Posted January 6, 2024 Author Share Posted January 6, 2024 (edited) 3 hours ago, Fantafaust said: Are you sure the alias is filling, and the quest is started? Ensure the player alias is marked optional or it could stop the quest from starting. Okay ... first thing: Thank you for your assistance. Second thing: I have no idea what just happened. I tried setting it as "optional" and it still didn't work. Then I incorporated "Hello World" into the quest, to make sure the quest was running, and it was showing the quest running. I then put "Hello World" inside the bottles script next to see if the script was being called, and it never showed the message. I scrapped the entire project and started fresh, and I'm pretty sure I did everything the same way I did before, but it started working. So much for a learning experience; I have no idea what I did wrong or right, on the first, second, third, etc attempts. After it started working, I tweaked some names and changed which bottle it gives back, and it still works. It's now gone from alpha to beta, and maybe I might release it to Nexus if it keeps working. (With credits to everyone). Addendum: I do see one difference between pre- and post- is that I don't have "Mandatory" on my properties anymore. I don't know if that means anything. Here's my final working script, in case anyone finds this post in five years and needs to know: Scriptname MK_BottlesBack_S extends ReferenceAlias ; ---------- Properties FormList Property MK_BottlesBack_L Auto Const Potion Property WaterPurified Auto Const MiscObject Property BeerBottleEmpty01 Auto Const ; ---------- Events Event OnAliasInit() RegisterForMenuOpenCloseEvent("CookingMenu") EndEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) If (abOpening == TRUE) Self.AddInventoryEventFilter(MK_BottlesBack_L) ElseIf (abOpening == FALSE) Self.RemoveInventoryEventFilter(MK_BottlesBack_L) Endif EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If (akBaseItem == WaterPurified) Game.GetPlayer().AddItem(BeerBottleEmpty01, 2, false) Endif EndEvent Edited January 6, 2024 by MartyrKomplx grammar/clarification Link to comment Share on other sites More sharing options...
Fantafaust Posted January 13, 2024 Share Posted January 13, 2024 Well that's odd. But still, glad it's working now Link to comment Share on other sites More sharing options...
Recommended Posts