Plarux Posted April 23, 2019 Share Posted April 23, 2019 (edited) Hello, I'm creating this post to find some insight on how to add items once a player crafts a specific object. There's multiple ways of doing this, but I think the easiest would be to make a script that checks to see if the player is at a crafting station and the item used for the recipe is removed from the player's inventory. For example, I've created this script below. It doesn't work, but it's the basis of getting this to function. I've done some googling, but can't figure out how to get the script to check & see if the player is crafting. IsFurnitureInUse can be used to do this though. However, I don't know how to make it work. If someone could help me get this to function properly, I would be extremely grateful! You will be credited too :smile: Scriptname PLSC_AddEmptyCoffeeTin extends ObjectReference MiscObject Property EmptyCoffeeTin Auto Const Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Game.GetPlayer.AddItem(EmptyCoffeeTin, 1, true) EndEvent Thank You,Plarux Edited April 23, 2019 by Plarux Link to comment Share on other sites More sharing options...
Zorkaz Posted April 23, 2019 Share Posted April 23, 2019 I'm curious about what you want to do. I mean what you describe is basically in the vanilla game, right? Link to comment Share on other sites More sharing options...
SKKmods Posted April 23, 2019 Share Posted April 23, 2019 a) WHAT are you trying to attach that script TO (the coffee tin, the workbench, the player ... ) ? b) HOW is the script going to receive the OnItemRemoved event without registering to receive it (You must use AddInventoryEventFilter to receive this event) ? Link to comment Share on other sites More sharing options...
hereami Posted April 23, 2019 Share Posted April 23, 2019 ...IsFurnitureInUse can be used... Try CurrentFurnitureHasKeyword(WorkbenchChemlab) e.g., and do whatever with OnItemAdded event. As above, curious, what's the goal. Assuming the script, want to make the component item not consumed by crafting? May add condition to the recipe GetItemCount(my component item)>0. Link to comment Share on other sites More sharing options...
Plarux Posted April 23, 2019 Author Share Posted April 23, 2019 (edited) To answer everyone's question, I want the script to add an item back to the player's inventory once they craft something. Since the Coffee Tin was used for one of my recipes, I wanted the player to receive the Empty Coffee Tin back. The OnItemRemoved is for the Coffee Tin used in the recipe, so when it's removed AND the player is in the crafting menu of the cooking station (or whatever station). This way the player will only get an empty coffee tin when they use the recipe requiring the coffee tin. Zorkaz, I can't find anything that does this. Nor any information on the web that has helped make it possible. The item being crafted is a Potion. SKK50, a) The Coffee Tin used for the recipe at a cooking station. b) I read about that on the creation kit website, but not really sure what it is :sad: hereami, Not sure how I would incorporate that into the script tbh. Edited April 23, 2019 by Plarux Link to comment Share on other sites More sharing options...
Hoamaii Posted April 23, 2019 Share Posted April 23, 2019 You could try and attach this type of script directly on your craftable Form in the CK: MiscObject Property EmptyCoffeeTin Auto Furniture Property MyCraftingStation Auto Event OnInit() If MyCraftingStation.IsFurnitureInUse() PlayerRef.AddItem(EmptyCoffeeTin, 1) EndIf EndEvent I just tested it last night - OnInit() fires on newly crafted objects. But since it will also fire whenever you drop the object or pick it up, you need to restrict this event to fire only when whatever Workbench you want is being used. That way you won't need a filter. Link to comment Share on other sites More sharing options...
SKKmods Posted April 23, 2019 Share Posted April 23, 2019 The approach I would suggest is to attach a script to the player by creating a start game enabled quest, adding a Reference alias which is filled with Unique Actor Player, then attaching a new script to the reference alias. The script would look something like (your gonna need to look this stuff up and create properties and such hygene); Event OnAliasInit() RegisterForMenuOpenCloseEvent("CookingMenu") ;Cooking + Chemlab RegisterForMenuOpenCloseEvent("ExamineMenu") ;Armor + Weapons EndEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) If (abOpening == TRUE) Self.AddInventoryEventFilter(FormListOfStuffIamInterestedIn) ElseIf (abOpening == FALSE) Self.RemoveInventoryEventFilter(FormListOfStuffIamInterestedIn) Endif EdnEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) ;do things based on the akBaseItem that has appeared in player inventory EndEvent Link to comment Share on other sites More sharing options...
Plarux Posted May 15, 2019 Author Share Posted May 15, 2019 The approach I would suggest is to attach a script to the player by creating a start game enabled quest, adding a Reference alias which is filled with Unique Actor Player, then attaching a new script to the reference alias. The script would look something like (your gonna need to look this stuff up and create properties and such hygene); Event OnAliasInit() RegisterForMenuOpenCloseEvent("CookingMenu") ;Cooking + Chemlab RegisterForMenuOpenCloseEvent("ExamineMenu") ;Armor + Weapons EndEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) If (abOpening == TRUE) Self.AddInventoryEventFilter(FormListOfStuffIamInterestedIn) ElseIf (abOpening == FALSE) Self.RemoveInventoryEventFilter(FormListOfStuffIamInterestedIn) Endif EdnEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) ;do things based on the akBaseItem that has appeared in player inventory EndEvent Okay, so my properties would be an Object Reference with linked to the empty coffee tin, the Form List with the empty coffee tin in it, and one for the cooking menu (not sure how I'd add this property). Please let me know if this is correct? Link to comment Share on other sites More sharing options...
SKKmods Posted May 16, 2019 Share Posted May 16, 2019 The properties you will want (I feel dirty typing this as its fish rather than fishing rod in the learning stuff context): FormList Property FormListOfStuffIamInterestedIn Auto Const Mandatory MiscObject property myCoffeeTin Auto Const Mandatory ;or whatever you have called your object The properties are associated with forms in the [Property] button on the script UI. Have a read of OnItemAdded - ObjectReference and see if you can figure out how to evaluate myCoffeeTin (or whatever you have called your object) against akBaseItem. Link to comment Share on other sites More sharing options...
Plarux Posted May 18, 2019 Author Share Posted May 18, 2019 (edited) The properties you will want (I feel dirty typing this as its fish rather than fishing rod in the learning stuff context): FormList Property FormListOfStuffIamInterestedIn Auto Const Mandatory MiscObject property myCoffeeTin Auto Const Mandatory ;or whatever you have called your object The properties are associated with forms in the [Property] button on the script UI. Have a read of OnItemAdded - ObjectReference and see if you can figure out how to evaluate myCoffeeTin (or whatever you have called your object) against akBaseItem. SKK50, I appreciate the help a lot. I'm learning as I go, so my apologies for my lack of knowledge. :/ If I were doing this with multiple different recipes, how would I do it? Multiple different scripts and quests or just scripts on the same quest alias? Here is the script that I tested. It adds an empty coffee tin when the player crafts a cup of dirty coffee. Scriptname PLSC_ECT_Script extends ReferenceAlias FormList Property PLSC_CoffeeDirtyCreatedFormList Auto Const Mandatory Potion Property CupofCoffee_Dirty Auto Const Mandatory MiscObject Property PLSC_CoffeeTin01 Auto Const Mandatory Event OnAliasInit() RegisterForMenuOpenCloseEvent("CookingMenu") ;Cooking + Chemlab EndEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) If (abOpening == TRUE) Self.AddInventoryEventFilter(PLSC_CoffeeDirtyCreatedFormList) ElseIf (abOpening == FALSE) Self.RemoveInventoryEventFilter(PLSC_CoffeeDirtyCreatedFormList) Endif EndEvent Event OnItemAdded(Form CupofCoffee_Dirty, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Game.GetPlayer().AddItem(PLSC_CoffeeTin01, 1, true) EndEvent Edited May 18, 2019 by Plarux Link to comment Share on other sites More sharing options...
Recommended Posts