Magicockerel Posted November 1, 2018 Share Posted November 1, 2018 For some reason Self on a script attached to an Activator returns the script itself and not the form. Not that it really matters where I use it, but I've given an example below. For reference, the activator is a constructable object that you can build at settlements. In this context, the akReference parameter returns the workshop at which the object was placed, and not the object reference unfortunately. I am not wanting to instead attach the script to the workshop itself in order for akReference to return any object built at that settlement. Event OnWorkshopObjectPlaced(ObjectReference akReference) Debug.Notification(asNotificationText = "Self = " + Self As Activator) EndEvent When I go to compile the script I get the following error message, "cannot cast a NameOfTheScript to a activator, types are incompatible". If you write Self to the script log, you will indeed see that Self returns the script rather than form. The only thread that I was able to find that could potentially help me out did not find the solution. You can find said thread here. If anyone knows of a simple way to return the reference that the script is attached to, rather than the script itself, please let me know. Link to comment Share on other sites More sharing options...
DieFeM Posted November 1, 2018 Share Posted November 1, 2018 (edited) An Activator is a base object, Self is an ObjectReference, you can't cast a reference to a base object, it would compile if you put Self.GetBaseObject() As Activator (for the base object), or simply Self (for the reference). PS: When you attach an script to a base object it is actually attached to the reference of the objects that you place, not to the base object itself, so the script extends ObjectReference not Activator. Edited November 1, 2018 by DieFeM Link to comment Share on other sites More sharing options...
Magicockerel Posted November 1, 2018 Author Share Posted November 1, 2018 Thanks, I've only started working with WorldObjects recently, so there's a lot that I don't know about them. That actually cleared a lot up, as I had made a number of poor assumptions that left me confused. I did a few tests and made the wrong conclusions, but going back over things now I think I have it mostly worked out. Link to comment Share on other sites More sharing options...
Recommended Posts