Magicockerel Posted January 4, 2017 Share Posted January 4, 2017 I'm wanting to use Events and Functions that are intended for an ObjectReference on a Flora form (e.g. FloraMutfruit01). Unfortunately, I can't simply cast a Flora form as an ObjectReference, as it tells me that they're incompatible types (e.g. casting "FloraMutfruit01 As ObjectReference" just gives me errors, where FloraMutfruit01 is a Flora form). The only way that I've been able to use Events and Functions intended for an ObjectReference on a Flora form is by attaching a script directly to the Flora form. I'm assuming that this works because it Extends an ObjectReference (why this works and casting "FloraMutfruit01 As ObjectReference" doesn't, I have no idea). This allows me to substitute "Self" for casting "FloraMutfruit01 As ObjectReference" (and as I've said, the latter solution doesn't compile). A working example of directly attaching the script to FloraMutfruit01 and using Self would be: ScriptName AH_FLOR_FloraMutfruit01_Script Extends ObjectReference Const Actor Property PlayerRef Auto Const Event OnInit() RegisterForDistanceLessThanEvent(akObj1 = PlayerRef, akObj2 = Self, afDistance = 100.0) EndEvent Event OnDistanceLessThan(ObjectReference akObj1, ObjectReference akObj2, Float afDistance) If (akObj1 == PlayerRef && akObj2 == Self) Debug.Notification("Distance < 100 units.") EndIf EndEventOr at least, that's an extract from a larger script that only shows what I'm talking about. It compiles, so it should work in-game like the aforementioned larger script. My issue is that I want to add this script to an alias, so that I can leave the vanilla form untouched (to maintain compatibility with other mods) and because I'll be doing this with 40+ other Flora forms, which would be a pain in the ass to do manually, and would feel sloppy. For greater specifics, you can see in this thread that I've made a Reference Alias using a FormList of the 40+ Flora forms that I plan to attach this script to. This means that the script Extends a ReferenceAlias, not an ObjectReference. As the script isn't directly attached to the Flora form, this means that I'm unable to use Self when attaching the script to an alias. I also looked at adding the Flora forms as properties to a script that I directly attached to a quest, but I haven't had any luck with that either. Any help would be appreciated, as I lack the experience to translate what I've done by directly attaching the script to the Flora form to an alias. Link to comment Share on other sites More sharing options...
kitcat81 Posted January 4, 2017 Share Posted January 4, 2017 (edited) Change to this : If (akObj1 == PlayerRef && akObj2 == Self.GetReference()) Debug.Notification("Distance < 100 units.")Then it will compile with reference alias script.I think it`s because alias has no reference until it`s filled so it needs to get the reference of the filling object. Edited January 4, 2017 by kitcat81 Link to comment Share on other sites More sharing options...
Magicockerel Posted January 4, 2017 Author Share Posted January 4, 2017 Change to this : If (akObj1 == PlayerRef && akObj2 == Self.GetReference()) Debug.Notification("Distance < 100 units.")Then it will compile with reference alias script.I think it`s because alias has no reference until it`s filled so it needs to get the reference of the filling object. Things seem to be working now, thanks a lot mate :) That's the second time I've felt like an idiot today - I've seen the ReferenceAlias related functions numerous times on the CK wiki, but I didn't think to take a look at them for whatever reason. Link to comment Share on other sites More sharing options...
kitcat81 Posted January 4, 2017 Share Posted January 4, 2017 (edited) Change to this : If (akObj1 == PlayerRef && akObj2 == Self.GetReference()) Debug.Notification("Distance < 100 units.")Then it will compile with reference alias script.I think it`s because alias has no reference until it`s filled so it needs to get the reference of the filling object. Things seem to be working now, thanks a lot mate :smile: That's the second time I've felt like an idiot today - I've seen the ReferenceAlias related functions numerous times on the CK wiki, but I didn't think to take a look at them for whatever reason. That`s no wonder , it`s not always obvious what the CK wants from you. :smile:When I get such types of errors and don`t know what can cause it, I just try all possible combinations until I find the proper one :tongue:. Here is my list of "As":as formas objectreferenceas actoras scriptname(if the object has attached scripts)Self.GetReference() - in most cases helps with reference alias script. Edited January 4, 2017 by kitcat81 Link to comment Share on other sites More sharing options...
Magicockerel Posted January 4, 2017 Author Share Posted January 4, 2017 Haha, that sounds about right, thanks again. Link to comment Share on other sites More sharing options...
Recommended Posts