niston Posted March 20, 2019 Share Posted March 20, 2019 So I have Scriptname MyScript extends ObjectReference CustomEvent MyEvent ; rest of the script This is attached to some furniture. Attached to the same furniture, there is MyOtherScript, where I have: MyScript refMyScript = none Event OnInit() refMyScript = ((Self as BaseClass) as ObjectReference) as MyScript ; various code ommitted RegisterForRemoteEvent(refMyScript, "MyEvent") ; this is line #117 EndEvent ; more code here MyScript.MyEvent(ObjectReference akSender, Bool bSomeParameter) ; this is line #154 ; some code here EndEvent Yet..... Papyrus Compiler Version 2.8.0.4 for Fallout 4Copyright © ZeniMax Media. All rights reserved.Starting 1 compile threads for 1 files...Compiling "MyOtherScript.psc"......Blahblah\MyScript.psc(117,44): MyEvent is not an event on MyScript or one if its parents...Blahblah\MyScript.psc(154,0): MyScript.MyEvent does not exist because MyScript cannot generate MyEvent eventsNo output generated for MyOtherScript.psc, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on MyOtherScript.psc I find myself staring at these error messages in utter disbelief, like, "uhhhhhhh.... wut?" Very clearly, the type of refMyScript is MyScript. And MyEvent is declared at the very top of MyScript. Indeed it is. MyScript wouldn't even compile if it weren't - I checked, just to make 100% sure. So what in the bloody hell of eternal doom is the compiler yapping about MyEvent not being an event on MyScript....? :pinch: I worked around by using a function instead of the event. Still, I'd like to know: WTF? What kind of blasphemy is this?! :ermm: Is my compiler possessed? :devil: Link to comment Share on other sites More sharing options...
DieFeM Posted March 20, 2019 Share Posted March 20, 2019 Use RegisterForCustomEvent instead of RegisterForRemoteEvent. Link to comment Share on other sites More sharing options...
niston Posted March 20, 2019 Author Share Posted March 20, 2019 (edited) But it's a remote script? When to use which? Its completely unclear from the wiki... Edited March 20, 2019 by niston Link to comment Share on other sites More sharing options...
DieFeM Posted March 20, 2019 Share Posted March 20, 2019 MyScript refMyScript = none Event OnInit() refMyScript = (Self as ObjectReference) as MyScript ; various code ommitted RegisterForCustomEvent(refMyScript, "MyEvent") ; this is line #117 EndEvent ; more code here Event MyScript.MyEvent(MyScript akSender, Var[] akArgs) ; this is line #154 ; some code here EndEvent akArgs are defined in MyScript when you send the custom event (SendCustomEvent) Link to comment Share on other sites More sharing options...
SKKmods Posted March 20, 2019 Share Posted March 20, 2019 (edited) If, like me, you are confused by swords and dragons in the unclear CK examples, always search your ...\Data\Scripts\Source\Base scripts for examples in context: The ever useful WorkshopParentScript both defines a custom event: CustomEvent WorkshopInitializeLocation and then registers for its own event:Self.RegisterForCustomEvent(Self, "WorkshopInitializeLocation") and then sends it:SendCustomEvent("WorkshopInitializeLocation") and then receives it:Event WorkshopParentScript.WorkshopInitializeLocation(WorkshopParentScript akSender, Var[] akArgs) Edited March 20, 2019 by SKK50 Link to comment Share on other sites More sharing options...
niston Posted March 20, 2019 Author Share Posted March 20, 2019 (edited) RegisterForCustomEvent seems to work. Fun is, I've already used both Custom and Remote in my own scripts, but still got a confuzzle at times. Sooo.... As a general rule of thumb: If the two scripts are attached to the same object, RegisterForCustomEvent is used and if they are attached to two different objects, Register ForRemoteEvent is used? Edited March 20, 2019 by niston Link to comment Share on other sites More sharing options...
DieFeM Posted March 20, 2019 Share Posted March 20, 2019 If you are working with a custom event then use RegisterForCustomEvent, otherwise use RegisterForRemoteEvent.You don't need to use RegisterForRemoteEvent when the event is being received from the Actor/ObjectReference where the script is attached, but if you are sending a custom event you always need register for it, it doesn't matter if is the same script or another script, or if it is in the same object or another object or form. Link to comment Share on other sites More sharing options...
niston Posted March 20, 2019 Author Share Posted March 20, 2019 So *ForRemoteEvent is for built-in events only? And whenever I use CustomEvent, I'll have to use *ForCustomEvent? Link to comment Share on other sites More sharing options...
DieFeM Posted March 20, 2019 Share Posted March 20, 2019 Right. Link to comment Share on other sites More sharing options...
niston Posted March 20, 2019 Author Share Posted March 20, 2019 (edited) Ok. Evil spirits of confuzzlement have been exorcised. Thank you :D Edited March 20, 2019 by niston Link to comment Share on other sites More sharing options...
Recommended Posts