GrimGrim31 Posted February 11, 2022 Share Posted February 11, 2022 Has anyone used the Custom Events in the WorkshopParentScript? I am trying to register for one of the custom events in one of my scripts and have not yet figured out how to register.I tried this line inside of an OnInit() function but it does not compile. RegisterForCustomEvent(Actor akSender, "WorkshopActorAssignedToWork") The error message in the compiler states that there is no viable alternative at input 'akSender'. The custom event in the WorkshopParentScript is part of the function AssignActorToObject(WorkshopNPCScript assignedActor, WorkshopObjectScript assignedObject, bool bResetMode = false, bool bAddActorCheck = true) on line 1334 of the script. The custom event line in that function is SendCustomEvent("WorkshopActorAssignedToWork", kargs) Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 11, 2022 Share Posted February 11, 2022 Reading the wiki page may be of help here. In a nutshell, you cannot use "Actor akSender" as the first parameter. Instead it needs to be an explicitly stated object that will be sending the custom event stated in the second parameter. ***************Disclaimer - My working knowledge of Papyrus stems from Skyrim. While it gives the ability to read, infer and surmise the workings of FO4 specific events and functions, it does not give practiced knowledge. Anything stated should be taken with a grain of salt and leeway applied for any misunderstandings due to FO4 specifics. Link to comment Share on other sites More sharing options...
LarannKiar Posted February 11, 2022 Share Posted February 11, 2022 Quest Property WorkshopParent Auto Const Event OnQuestInit() RegisterForCustomEvent(WorkshopParent as WorkshopParentScript, "WorkshopActorAssignedToWork") EndEvent akSender is not the workshop actor, it's the WorkshopParentScript. How to get the workshop actor: Event WorkshopParentScript.WorkshopActorAssignedToWork(WorkshopParentScript akSender, var[] arguments) ; Arguments sent by the event ObjectReference assignedObject = arguments[0] as ObjectReference ObjectReference WorkshopRef = arguments[1] as ObjectReference ; Get the assigned Workshop Actor WorkshopNPCScript AssignedWorkshopActor If assignedObject as WorkshopObjectScript AssignedWorkshopActor = (assignedObject as WorkshopObjectScript).GetAssignedActor() as WorkshopNPCScript EndIf EndEvent AssignedWorkshopActor is the workshop actor. Link to comment Share on other sites More sharing options...
GrimGrim31 Posted February 12, 2022 Author Share Posted February 12, 2022 (edited) Thank you. I read the wiki page while I was working on my script but it still leaves me wondering what is the ScriptObject akSender in the Function RegisterForCustomEvent(ScriptObject akSender, CustomEventName asEventName) native for the Custom event that I wish to use. Should the ScriptObject be WorkshopParentScript or the AssignedWorkshopActor or the assignedObject? EDIT: It appears to be the script WorkshopParentScript using the property name that I gave it. Edited February 12, 2022 by GrimGrim31 Link to comment Share on other sites More sharing options...
LarannKiar Posted February 12, 2022 Share Posted February 12, 2022 Thank you. I read the wiki page while I was working on my script but it still leaves me wondering what is the ScriptObject akSender in the Function RegisterForCustomEvent(ScriptObject akSender, CustomEventName asEventName) native for the Custom event that I wish to use. Should the ScriptObject be WorkshopParentScript or the AssignedWorkshopActor or the assignedObject? The custom event is generated by a script (ScriptObject) so akSender is the WorkshopParentScript. Link to comment Share on other sites More sharing options...
Recommended Posts