corpseletter Posted June 4, 2024 Share Posted June 4, 2024 I am trying to trigger the workbenchscript so my invisible workbench can access it and use items/components stored in settlements during crafting. Function CreateFurniture(ObjectReference akFurnitureRef) If akFurnitureRef.HasKeyword(sc_kywd_AnimArmor) InvisibleFurniture = akFurnitureRef.PlaceAtMe(sc_CraftbenchArmor) ElseIf akFurnitureRef.HasKeyword(sc_kywd_AnimWeapon) InvisibleFurniture = akFurnitureRef.PlaceAtMe(sc_CraftbenchWeapon) EndIf Utility.Wait(0.1) RegisterForRemoteEvent(PlayerRef, "OnGetUp") RegisterForRemoteEvent(InvisibleFurniture, "OnActivate") InvisibleFurniture.Activate(PlayerRef, True) EndFunction All these works, but I'm stuck on Event OnActivate(ObjectReference akActionRef) EndEvent I can't compile it. CK throws this error: sc_qust_StartupQuest.psc(31,0): new event onactivate cannot be defined because the script is not flagged as native I tried doing ObjectReference.OnActivate but CK threw out a different error: sc_qust_StartupQuest.psc(31,0): the parameter types of function objectreference.onactivate in the empty state on script simplecraft:sc_qust_startupquest do not match the original script objectreference Link to comment Share on other sites More sharing options...
SKKmods Posted June 4, 2024 Share Posted June 4, 2024 A script attached to a quest form will not receive OnActivate events from arbitrary objects. SOLUTION A That quest script needs to remote register for the event https://falloutck.uesp.net/wiki/RegisterForRemoteEvent_-_ScriptObject example: Self.RegisterForRemoteEvent(akFurnitureRef, "OnActivate") and then ... Event ObjectReference.OnActivate(ObjectReference akSender, ObjectReference akActionRef) ;do stuff and dont forget to Self.UnregisterForRemoteEvent(akSender, "OnActivate") when complete EndEvent SOLUTION B Attach a script to the originating object and get its native OnActivate event to do stuff. SOLUTION C Attach a script to the originating object and get its native OnActivate event to call a function on the quest script (pQuestName as QuestNameScript).FunctionName() SOLUTION D Add the originating object to a quest reference alias which has an attached script that looks like B or C & etc Link to comment Share on other sites More sharing options...
corpseletter Posted June 4, 2024 Author Share Posted June 4, 2024 16 minutes ago, SKKmods said: A script attached to a quest form will not receive OnActivate events from arbitrary objects. That quest script needs to remote register for the event https://falloutck.uesp.net/wiki/RegisterForRemoteEvent_-_ScriptObject example: Self.RegisterForRemoteEvent(akFurnitureRef, "OnActivate") and then ... Event ObjectReference.OnActivate(ObjectReference akSender, ObjectReference akActionRef) ;do stuff and dont forget to Self.UnregisterForRemoteEvent(akSender, "OnActivate") when complete EndEvent Thanks! I was doing this before I came back and checked my thread: RegisterForRemoteEvent(InvisibleFurniture, "OnActivate") If !RegisterForRemoteEvent(InvisibleFurniture, "OnActivate") Debug.MessageBox("Failed to Register") Else Debug.MessageBox("Registered") InvisibleFurniture.Activate(PlayerRef, True) EndIf Does it have to be akFurnitureRef? With this, I was able to compile. In-game was showing a message box with "Registered" so it seems the event is registered but OnActivate event isn't happening: Event ObjectReference.OnActivate(ObjectReference akSender, ObjectReference akActionRef) Debug.MessageBox("Hello") EndEvent Link to comment Share on other sites More sharing options...
SKKmods Posted June 4, 2024 Share Posted June 4, 2024 Your best bet is to attach a script direct to InvisibleFurniture and test if that object actually triggers the OnActivate event. Link to comment Share on other sites More sharing options...
corpseletter Posted June 4, 2024 Author Share Posted June 4, 2024 12 minutes ago, SKKmods said: Your best bet is to attach a script direct to InvisibleFurniture and test if that object actually triggers the OnActivate event. Can I if it's just a variable? ;-- Variables --------------------------------------- ObjectReference InvisibleFurniture Link to comment Share on other sites More sharing options...
SKKmods Posted June 4, 2024 Share Posted June 4, 2024 Attach scripts to the base forms which are creating the spawned object ... sc_craftworkbenchname things. Link to comment Share on other sites More sharing options...
corpseletter Posted June 4, 2024 Author Share Posted June 4, 2024 1 hour ago, SKKmods said: Attach scripts to the base forms which are creating the spawned object ... sc_craftworkbenchname things. Ah, to the furniture themselves? They do have the workbenchscript attached. Should I try to make a different one and try OnActivate in it? And just for full disclosure, here's the current script that I have. ScriptName SimpleCraft:sc_qust_StartupQuest Extends Quest ;-- Variables --------------------------------------- ObjectReference InvisibleFurniture ;-- Properties -------------------------------------- Actor Property PlayerRef Auto Const Perk Property sc_CraftPerk Auto Const Furniture Property sc_CraftbenchArmor Auto Const Furniture Property sc_CraftbenchWeapon Auto Const Keyword Property sc_kywd_AnimArmor Auto Const Keyword Property sc_kywd_AnimWeapon Auto Const ;-- Events --------------------------------------- Event OnQuestInit() If !PlayerRef.HasPerk(sc_CraftPerk) PlayerRef.AddPerk(sc_CraftPerk, False) EndIf EndEvent Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture) Utility.Wait(0.2) InvisibleFurniture.Disable(False) InvisibleFurniture.Delete() UnregisterForRemoteEvent(PlayerRef, "OnGetUp") EndEvent ;-- Functions --------------------------------------- Function CreateFurniture(ObjectReference akFurnitureRef) If akFurnitureRef.HasKeyword(sc_kywd_AnimArmor) InvisibleFurniture = akFurnitureRef.PlaceAtMe(sc_CraftbenchArmor) ElseIf akFurnitureRef.HasKeyword(sc_kywd_AnimWeapon) InvisibleFurniture = akFurnitureRef.PlaceAtMe(sc_CraftbenchWeapon) EndIf Utility.Wait(0.1) RegisterForRemoteEvent(PlayerRef, "OnGetUp") InvisibleFurniture.Activate(PlayerRef, True) EndFunction Link to comment Share on other sites More sharing options...
corpseletter Posted June 4, 2024 Author Share Posted June 4, 2024 InvisibleFurniture.Activate(PlayerRef, True) It was 'True' that was blocking the event being sent. My test script on one of the new workbenches works, but wouldn't workbenchscript also work now? Link to comment Share on other sites More sharing options...
corpseletter Posted June 5, 2024 Author Share Posted June 5, 2024 I fixed it now! WorkshopREF = akFurnitureRef.GetLinkedRef(WorkshopItemKeyword) as WorkshopScript InvisibleFurniture.SetLinkedRef(WorkshopREF, WorkshopItemKeyword) If (WorkshopREF && WorkshopREF.OwnedByPlayer == false) WorkshopREF.CheckOwnership() EndIf Link to comment Share on other sites More sharing options...
Recommended Posts