se7enraven Posted April 21, 2017 Share Posted April 21, 2017 I was wondering if there is such a thing as an inventory based workbench and/or if it is possible to make one? I'm really rusty on scripting, so please bear with me: In FONV, I had made a consumable item (Potion/Food), attached a script to enter a given workbench crafting screen once consumed, and upon exiting the crafting screen, replenish the used consumable item. This in effect, would would simulate an inventory item which serves as a workbench. Can anyone point me in the right direction with making this? Currently, I am able to create the following: -A new workbench, with custom recipes for said workbench. But I can only achieve this with furniture items, not consumables. -I am able use a "magic effect" to return an "MiscObject" via the "NukaColaBottleCapAdderSCRIPT", but this doesn't apply to "potion" (consumable) type objects. -I have also made a mobile crafting station by linking a mine weapon to spawn a crafting bench on explosion. The crafting bench itself is a "Prop" model so it can be picked up/moved. Ultimately I wish to make a crafting bench that is used in the inventory only, without having to drop it outside of the players inventory. Thank you for your time and any help would be greatly appreciated! Link to comment Share on other sites More sharing options...
scrivener07 Posted April 21, 2017 Share Posted April 21, 2017 I did something like this recently in a side project. You can adapt any part of it that you like for your own mod. The potion property acts like the inventory button and the furniture properties are the WorkBenches you want to open a menu for. ScriptName Fallout:FieldKits:Deploy extends Papyrus:Project:Modules:Required import Papyrus:Diagnostics:Log ; http://www.creationkit.com/fallout4/index.php?title=PlaceAtMe_-_ObjectReference ; http://www.creationkit.com/fallout4/index.php?title=Activate_-_ObjectReference UserLog Log ObjectReference Bench ; Message Options int NoneOption = -1 const int ExitOption = 0 const int WeaponOption = 1 const int ArmorOption = 2 const int PAOption = 3 const int CookOption = 4 const int ChemistryOption = 5 const bool Silent = true const bool DefaultProcessingOnly = true const ; Events ;--------------------------------------------- Event OnInitialize() Log = LogNew(Context.Title, self) EndEvent Event OnEnable() GiveKit() RegisterForRemoteEvent(Player, "OnItemEquipped") WriteLine(Log, "Deploy Module has been enabled.") EndEvent Event OnDisable() RemoveKits() DestroyBench() UnregisterForRemoteEvent(Player, "OnItemEquipped") WriteLine(Log, "Deploy Module has been disabled.") EndEvent Event Actor.OnItemEquipped(Actor akSender, Form akBaseObject, ObjectReference akReference) If (akBaseObject == Fallout_FieldKits_Kit) If (Utility.IsInMenuMode()) Fallout_FieldKits_KitExitMenuMessage.Show() EndIf Utility.Wait(0.1) GiveKit() PromptOptions() EndIf EndEvent Event ObjectReference.OnExitFurniture(ObjectReference akSender, ObjectReference akActionRef) If (akSender == Bench) WriteLine(Log, "The player is exiting the bench.") DestroyBench() Else WriteLine(Log, "OnExitFurniture sender was '"+akSender+"', expected '"+Bench+"'.") EndIf EndEvent Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture) WriteLine(Log, "The player is getting up from the bench.") DestroyBench() EndEvent ; Functions ;--------------------------------------------- Function PromptOptions() int selected = Fallout_FieldKits_BenchOptionsMessage.Show() If (selected == NoneOption || selected == ExitOption) WriteLine(Log, "Selected NoneOption or ExitOption.") return ElseIf (selected == WeaponOption) WriteLine(Log, "Selected WeaponOption.") CreateBench(Fallout_FieldKits_BenchWeapon) ElseIf (selected == ArmorOption) WriteLine(Log, "Selected ArmorOption.") CreateBench(Fallout_FieldKits_BenchArmor) ElseIf (selected == PAOption) WriteLine(Log, "Selected PAOption.") CreateBench(Fallout_FieldKits_BenchPA) ElseIf (selected == CookOption) WriteLine(Log, "Selected CookOption.") CreateBench(Fallout_FieldKits_BenchCook) ElseIf (selected == ChemistryOption) WriteLine(Log, "Selected ChemistryOption.") CreateBench(Fallout_FieldKits_BenchChemistry) Else WriteLine(Log, "Unhandled option selected: " + selected) EndIf EndFunction Function CreateBench(Furniture aFurniture) DestroyBench() Bench = Player.PlaceAtMe(aFurniture) If (Bench) Bench.SetAngle(0.0, 0.0, Bench.GetAngleZ()) RegisterForRemoteEvent(Bench, "OnExitFurniture") RegisterForRemoteEvent(Player, "OnGetUp") Game.ForceFirstPerson() InputEnableLayer input = InputEnableLayer.Create() input.DisablePlayerControls() If (Bench.Activate(Player, DefaultProcessingOnly)) WriteLine(Log, "Activated bench. " + Bench) Else WriteLine(Log, "Could not activate bench.") DestroyBench() EndIf input.EnablePlayerControls() Else DestroyBench() WriteLine(Log, "Could not create a new bench.") EndIf EndFunction Function DestroyBench() If (Bench) UnregisterForRemoteEvent(Bench, "OnExitFurniture") UnregisterForRemoteEvent(Player, "OnGetUp") Bench.Disable() Bench.Delete() WriteLine(Log, "Destroyed a bench. " + Bench) Else WriteLine(Log, "There is no bench to destroy.") EndIf EndFunction Function GiveKit() If (Count == 0) Player.AddItem(Fallout_FieldKits_Kit, 1, Silent) WriteLine(Log, "Gave the player one kit.") Else WriteLine(Log, "The player already has a kit.") EndIf EndFunction Function RemoveKits() If (Count > 0) Player.RemoveItem(Fallout_FieldKits_Kit, Count, Silent) WriteLine(Log, "Removed all kits from the player.") Else WriteLine(Log, "There are no kits to remove from the player.") EndIf EndFunction ; Properties ;--------------------------------------------- Group Kit Potion Property Fallout_FieldKits_Kit Auto Const Mandatory Message Property Fallout_FieldKits_KitExitMenuMessage Auto Const Mandatory int Property Count Hidden int Function Get() return Player.GetItemCount(Fallout_FieldKits_Kit) EndFunction EndProperty EndGroup Group Bench Message Property Fallout_FieldKits_BenchOptionsMessage Auto Const Mandatory Furniture Property Fallout_FieldKits_BenchWeapon Auto Const Mandatory Furniture Property Fallout_FieldKits_BenchArmor Auto Const Mandatory Furniture Property Fallout_FieldKits_BenchPA Auto Const Mandatory Furniture Property Fallout_FieldKits_BenchCook Auto Const Mandatory Furniture Property Fallout_FieldKits_BenchChemistry Auto Const Mandatory EndGroup Link to comment Share on other sites More sharing options...
se7enraven Posted April 25, 2017 Author Share Posted April 25, 2017 Thank you! I'll have to mess around with it and see how it works. Is this a single script saved as a magic effect? Link to comment Share on other sites More sharing options...
scrivener07 Posted April 26, 2017 Share Posted April 26, 2017 Try this one as the above requires libraries you dont have. This one is attached to a Quest and then its properties should be filled. You need one potion for the inventory item, one message to tell the player to close the pipboy if needed, and then and invisible version of the bench furniture you want to open. The behavior of this one is simpler. When the potion item is consumed a workbench it created and activated immediately instead of a messagebox menu to choose the bench type. ScriptName Derp extends Quest Actor Player ObjectReference BenchReference Event OnInit() Player = Game.GetPlayer() EndEvent Event OnQuestInit() RegisterForRemoteEvent(Player, "OnItemEquipped") EndEvent Event OnQuestShutdown() DestroyBench() UnregisterForRemoteEvent(Player, "OnItemEquipped") EndEvent Event Actor.OnItemEquipped(Actor akSender, Form akBaseObject, ObjectReference akReference) If (akBaseObject == MyPotion) If (Utility.IsInMenuMode()) MyExitMessage.Show() EndIf Utility.Wait(0.1) Player.AddItem(MyPotion, 1, true) ; re-add for reusable items CreateBench(MyWorkBench) ; pass in the furniture to create/activate EndIf EndEvent Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture) DestroyBench() EndEvent Function CreateBench(Furniture aFurniture) DestroyBench() BenchReference = Player.PlaceAtMe(aFurniture) If (BenchReference) BenchReference.SetAngle(0.0, 0.0, BenchReference.GetAngleZ()) RegisterForRemoteEvent(Player, "OnGetUp") InputEnableLayer input = InputEnableLayer.Create() input.DisablePlayerControls() If (BenchReference.Activate(Player, true) == false) DestroyBench() EndIf input.EnablePlayerControls() Else DestroyBench() EndIf EndFunction Function DestroyBench() If (BenchReference) UnregisterForRemoteEvent(Player, "OnGetUp") BenchReference.Disable() BenchReference.Delete() BenchReference = none EndIf EndFunction Group Properties Potion Property MyPotion Auto Const Mandatory {The token activation item} Message Property MyExitMessage Auto Const Mandatory {Exit the menu to use the workbench} Furniture Property MyWorkBench Auto Const Mandatory {The workbench to activate} int Property Count Hidden int Function Get() return Player.GetItemCount(MyPotion) EndFunction EndProperty EndGroup Its untested as I just yanked it out of my larger project. Its up to you to tweak and make it work. Link to comment Share on other sites More sharing options...
se7enraven Posted April 30, 2017 Author Share Posted April 30, 2017 Thank you for your help! I tried the last script you posted, and it saved fine and I was able to add the potion item, message and workbench in the fields. When I test it out in game, the potion item is consumed and nothing else happens. Does the potion item need another script to link to the quest itself or should it perform automatically on consumption? I worked on it for awhile and do not understand what I am missing. On a side note, I was able to make a simple script which returns the potion item consumed, but still need to figure out how to activate the workbench. -Peace! Link to comment Share on other sites More sharing options...
scrivener07 Posted April 30, 2017 Share Posted April 30, 2017 Does your quest have the "Start Game Enabled" flag? Try adding Debug.MessageBox("FunctionName") to the first line of each event and function. Link to comment Share on other sites More sharing options...
se7enraven Posted April 30, 2017 Author Share Posted April 30, 2017 (edited) It works! I just tested it ingame and used an earlier save. Thank you so much, I really, REALLY appreciate it! I can do simple models and textures, if you ever need anything, please let me know! -Peace! Edited April 30, 2017 by se7enraven Link to comment Share on other sites More sharing options...
jags78 Posted February 21, 2019 Share Posted February 21, 2019 hi scrivener07 You're script is extremly interesing. Clean, elegant and simple to read. +1 Kudos from me. Really learned something. Thx jags78 Link to comment Share on other sites More sharing options...
scrivener07 Posted November 5, 2019 Share Posted November 5, 2019 Since Ive got some messages about this script all these years later I hereby declare the above papyrus source code as licensed under MIT with no explicit copyright notice, just the liability disclaimer. Hope to see someone pick this up and make a release out of it. Link to comment Share on other sites More sharing options...
Recommended Posts