F4llfield Posted April 16, 2023 Share Posted April 16, 2023 (edited) Hi, I would like to detect when the player select the settlement workbench (the first time) after completing the settlement ownership quest. I'm not sure how to approach this one. Any ideas will be appreciated. Edited April 16, 2023 by F4ll0uta Link to comment Share on other sites More sharing options...
SKKmods Posted April 16, 2023 Share Posted April 16, 2023 The first time a red WorkShop is activated the script event OnActivate() will trigger, although you should check if the workshop is infact owned. Self.RegisterForRemoteEvent(thisWorkshop, "OnActivate") Event ObjectReference.OnActivate(ObjectReference akSender, ObjectReference akActivator) If (akActivator == Game.GetPlayer()) && (akSender as WorkshopScript).OwnedByPlayer == True) Self.UnRegisterForRemoteEvent(akSender, "OnActivate") ;do stuff EndIIf EndEvent After the first activation it does not trigger OnActivate as the workshop enters building menu mode. Self.RegisterForRemoteEvent(thisWorkshop, "OnWorkshopMode") Event ObjectReference.OnWorkshopMode(ObjectReference akSender, bool aStart) ;stuff EndEvent Link to comment Share on other sites More sharing options...
F4llfield Posted April 16, 2023 Author Share Posted April 16, 2023 Thanks SKK50. The only part I'm struggling with is the registration. I want "thisWorkshop" to be all settlements workshop (Red Bench). Do I need a registration for every single workbench ? Link to comment Share on other sites More sharing options...
SKKmods Posted April 16, 2023 Share Posted April 16, 2023 Yes you will need to register each individual object reference by iterating the registered workshop list: While (pWorkshopParent.GetStage() < 20) ; not finished registering Utility.WaitmenuMode(5.0) EndWhile WorkshopScript[] WorkshopREFs = (pWorkshopParent as WorkshopParentScript).Workshops Int iIndex = 0 While (iIndex < WorkshopREFs.Length) ObjectReference thisWorkshop = WorkshopREFs[iIndex] as ObjectReference Self.RegisterForRemoteEvent(thisWorkshop, "OnActivate") iIndex +=1 EndWhile Endif Link to comment Share on other sites More sharing options...
F4llfield Posted April 17, 2023 Author Share Posted April 17, 2023 Thanks again SKK50. Its working. But I'm not sure why the first while loop (with the waitmenumode) is outside the registration loop? Link to comment Share on other sites More sharing options...
SKKmods Posted April 17, 2023 Share Posted April 17, 2023 If your mod is loaded in a new game start the workshops may not have registered with WorkshopParentScript which can take up to TWO MINUTES from the initial mirror scene looks menu to complete. Not many mod authors consider or understand the new game start conditons which is why so much stuff doesnt actually work or inventory items are missing. Link to comment Share on other sites More sharing options...
F4llfield Posted April 17, 2023 Author Share Posted April 17, 2023 Thanks for the information. Link to comment Share on other sites More sharing options...
Recommended Posts