marieruth Posted November 22, 2014 Share Posted November 22, 2014 If I use Self.Delete() within a script that is attached to an activator, for example, would Self.Delete() remove the activator from the world in-game? Does it function similar to RemoveMe? Link to comment Share on other sites More sharing options...
DDProductions83 Posted November 22, 2014 Share Posted November 22, 2014 I have only seen self work as a object reference in relation to the object the script is attached toIE it should theoretically work as a actor if the script extends actor and work as a alias if the script extends alias..Someone might know more but I always use it as a Objectreference sooooo ya that probably didnt help lol Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 22, 2014 Share Posted November 22, 2014 If your script extends ObjectReference, you can use Self.Delete(). Otherwise you might need to cast into an ObjectReference or obtain the ObjectReference in some way. Link to comment Share on other sites More sharing options...
ArronDominion Posted November 22, 2014 Share Posted November 22, 2014 (edited) Activator extends Form so Activator scripts gain all of the functionality that is inherent to Form in addition to what Activator has (yay O.O. concepts). Looking at the API on the wiki shows that Delete() is not a member function of either Activator (which has nothing inherent to it o.o) or Form. You would need to place the Activator within the world, then attach a script to the world object that is an ObjectReference script (or a script that extends ObjectReference if you need access to any other functions inherent to that type of script, but that would be weird for an Activator). Edit:You can cast it as an ObjectReference or find another method to obtain it. Know casting can have some weird voodoo if done incorrectly. Edited November 22, 2014 by Arron Dominion Link to comment Share on other sites More sharing options...
marieruth Posted November 22, 2014 Author Share Posted November 22, 2014 I should probably be a little more specific. I'm using this tutorial to make a spell for myself: http://sureai.net/development/tutorials/skyrim-creation-kit-location-based-spells/ And in that tutorial, it uses this script that has to be attached to an activator, and that activator is attached to an explosion object, and that explosion object is to be attached to a magic effect, and the magic effect attached to the spell of course: http://i.imgur.com/tAfoDrK.png I was just wanting to summon a soil mound on the ground that you could use. So I thought this would work: Scriptname aaa_PlaceSoilMound extends ObjectReference {Script to place soil mound} ObjectReference refSoilMound Event OnInit() refSoilMound = Self.PlaceAtMe(Game.GetForm(0x00089A88)) ; Soil Mound = 0x00089A88 RegisterForSingleUpdate(0.5) endEvent Event OnUpdate() refSoilMound.Enable() Self.Delete() endEvent I originally used "PlayerRef" instead of "Self" but I didn't want the soil patch to spawn at the player, so I thought maybe Self be a better fit... Also, now that I think about it. Wouldn't Self.Delete remove more than just the marker anyhow? Link to comment Share on other sites More sharing options...
ArronDominion Posted November 22, 2014 Share Posted November 22, 2014 (edited) The original script was attached to an XMarker reference that was placed in the world, so self would refer to the XMarker reference that the tutorial uses for the Target Location spell. PlayerRef would cause weird behavior if you ended up deleting that, since there are other scripts that utilize it. Self is appropriate in this case. Self.Delete() will only call on the XMarker reference, since that is what the script is attached to. Edit: You probably want to have a method of some sort to clean up the soil since that seems like a potential memory leak in its current form (since you will spawn the object and there is no way to destroy it at the moment). As an aside, the method the tutorial/this script use to access the form leaves little room for error if that value ever changed (who knows what you would access), it probably would be better to try and use a Form property. Edited November 22, 2014 by Arron Dominion Link to comment Share on other sites More sharing options...
cdcooley Posted November 22, 2014 Share Posted November 22, 2014 If you ever find yourself writing "self.SomeFunction()" you can always just use "SomeFunction()" instead. Self is the object the script is attached to and the default thing that will be manipulated anyway. Self is in the language because sometimes you need to reference the current object in some other function. For example, you could attach this script to a container and when the player or other NPC activates the container everything worn and carried would be transferred to the container. And then if activated a second time everything would be transferred back. (The first RemoveAllItems line could be written "self.RemoveAllItems(triggerRef)" but the self isn't needed there.) ScriptName TransferToSelf extends ObjectReference bool haveStuff = false Event OnActivate(ObjectReference triggerRef) if haveStuff RemoveAllItems(triggerRef) haveStuff = false else triggerRef.RemoveAllItems(self) haveStuff = true endif EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts