Jump to content

Papyrus: Open Workbench


Recommended Posts

Hi!. I have a doubt about something to execute from papyrus. I would like to open the industrial workbench menu from an item that had been added to the player's inventory. I though using the .Activate from ObjectReference of a workbench added in a cell and called from a quest script would work.. but nope. this is the code I am using. (Thanks LarannKiar for the initial help on this topic)

Form Property ItemToOpenWorkbench Auto Const
ObjectReference Property ItemToOpenWorkbenchRef Auto Const
ObjectReference Property WorkbenchRef Auto Const

Event OnQuestInit()
    Actor PlayerRef = Game.GetPlayer()
    PlayerRef.AddItem(ItemToOpenWorkbenchRef, 1, False)
    RegisterForRemoteEvent(Game.GetPlayer(), "OnItemEquipped"); when the Player equips the item
EndEvent

Event Actor.OnItemEquipped(Actor akSender, Form akBaseObject, ObjectReference akReference)  ; event received
    Actor PlayerRef = Game.GetPlayer()
    PlayerRef.UnequipItem(ItemToOpenWorkbench, False, True)
    If akSender == PlayerRef && akBaseObject == ItemToOpenWorkbench; check sender and the equipped item
        Debug.ExecuteConsole("HideMenu InventoryMenu"); hide the menus
        Debug.ExecuteConsole("HideMenu DataMenu")
        Utility.Wait(1.0); wait until they are closed
        Debug.Notification(WorkbenchRef as string)
        bool bRun = WorkbenchRef.Activate(PlayerRef); activate the workbench reference to open the associated menu
        Debug.Notification(bRun as string)
    EndIf
EndEvent


I got the debug notification with the workbench ref and true of the activation.

image.png?ex=66977705&is=66962585&hm=549a273a6c3690f27d31f53e83f1f9062e24b56ead7572a07e4b8c028bea8e51&

The workbench is in a Cell to able get the reference from papyrus

image.png.c3cca7d9514eea3df6cdf6257b2ee820.png

image.png.85fe95c5ac1b5c011d5fa813e1b6561b.png

Link to comment
Share on other sites

Can you open this workbench with "Activate Player" after selecting it in the console?

While not the script specifically, I tested this code through the console; selected the Weapons Workbench which is in the Lodge basement (I was 5-6 yards away from it), closed the console, opened the DataMenu >> InventoryMenu, reopened the console then called the HideMenu commands, and once both the Inventory and DataMenu were closed, called "Activate Player". It worked for me. I also used this approach in Smart Captain's Planet Resource Database on a (3D unloaded) terminalRef to open the planet database (TerminalMenu).

I see the workbench you're attempting to open is not a vanilla reference and is probably in an unloaded interior cell. Try the code on one of the Lodge workbenches and make sure it's 3D loaded. One of the differences between TerminalMenu and WorkbenchIndustrialMenu is that the workbench animation "places" the player in front of the workbenchRef so if the workbenchRef is not 3D loaded then maybe it doesn't work, I don't know.. Also, check the Papyrus log (here's how to enable it) as it usually contains errors about function calls being dropped due to no 3D or initialized anim graph and the like.

Link to comment
Share on other sites

Posted (edited)

Thanks again to your response. After your suggestion the truth is that the workbench must be True with is3dLoaded(). I tested the script by setting in the parameters script the workbench in the lodge and worked as expected, I can even been in other location (within the Cell "The Lodge") stead in front of the bench and the menu open. The only caveat is when the menu close the player is "teletrasported" in front of the workbench.

But if I run the script in another location is doesn't open the workbench UI. So, may be I have to desist to the idea to have the workbench opened in anywhere. The object must be rendered in the world :o(

image.thumb.png.96e72d3918a52bc1943068e73dc731d6.png

Edited by Javapower77
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...