Difference between revisions of "User talk:Blebbleb123"
Jump to navigation
Jump to search
imported>Blebbleb123 (User talk:Blebbleb123 moved to How do you set a variable for the target of a spell?: Better Title) |
imported>DragoonWraith |
||
Line 1: | Line 1: | ||
Well, I'm trying to make a spell and I want to move an item to the target of the spell. This doesn't work because you can't do something like "Item.moveto spelltarget." I can't find any way to set a variable for the target, so I hope the wiki can help. | |||
:Hi Blebbleb123! | |||
:I think, [[GetSelf]] will work exactly at your option. | |||
:Just use | |||
<pre>ref target | |||
Begin ScriptEffectStart | |||
set target to getSelf | |||
end</pre> | |||
:--[[User:Diarrhoe|Diarrhoe]] 10:03, 27 November 2010 (EST) | |||
Thanks! Sorry if thats common knowledge... I'm new to moding | |||
:Hey, I've moved this here because questions like this don't go in the "Main" namespace, so I'm going to delete the other article. Your personal Talk page is the more appropriate place for this kind of thing. Anyway, yes, this is ''exactly'' what [[GetSelf]] is for, so you should use that. | |||
:One thing to remember (though you seem to understand this, I think) is that spell effect scripts run natively on the target (which is why GetSelf works in the first place; it returns the target instead of the spell because the game runs the script on the target). This means that you don't always need to use GetSelf (and often shouldn't). MoveTo is a perfect example of when you ''do'' need to use it, but it's a common mistake to over use it. As some examples, here's the basics of the script you want: | |||
ref target | |||
Begin ScriptEffectStart | |||
set target to GetSelf | |||
itemRef.MoveTo target | |||
End | |||
:vs. a script that moves the target somewhere else, like so: | |||
ref target | |||
Begin ScriptEffectStart | |||
set target to GetSelf | |||
target.MoveTo itemRef | |||
End | |||
:This second script I've written is "wrong" - it will work fine, but you don't need that ref variable and you don't need to call GetSelf. Doing so is redundant, and is less efficient than the script needs to be. Efficiency is ''very'' rarely a major concern in Oblivion scripting, but one should always avoid wasting processing when you don't have to. The second script above does the same as this (better) script: | |||
Begin ScriptEffectStart | |||
MoveTo itemRef | |||
End | |||
:Here, MoveTo isn't given a reference with the dot operator, so it will instead use the reference running the script - which in this case is the target of the spell, thereby achieving the same effect as the second script above, but saving memory and time by not using the ref variable or calling GetSelf needlessly. | |||
:So, in conclusion, for the script you requested, you need to use GetSelf and that's the correct thing to do. For a sort of opposite script, you wouldn't need to use it at all, and doing so is just wasteful. Since you'll usually want to move things to the target, it's pretty common to use GetSelf with MoveTo, but plenty of other functions don't need GetSelf at all. You only need GetSelf when you must pass the target of the spell as an argument (that is, after the function, rather than before the dot). | |||
:Hope that helps! | |||
:[[User:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">D</span>ragoon <span style="font-family: Oblivion, Daedric Runes; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">TALK</span>]] 21:50, 1 January 2011 (EST) |
Latest revision as of 21:50, 1 January 2011
Well, I'm trying to make a spell and I want to move an item to the target of the spell. This doesn't work because you can't do something like "Item.moveto spelltarget." I can't find any way to set a variable for the target, so I hope the wiki can help.
- Hi Blebbleb123!
- I think, GetSelf will work exactly at your option.
- Just use
ref target Begin ScriptEffectStart set target to getSelf end
- --Diarrhoe 10:03, 27 November 2010 (EST)
Thanks! Sorry if thats common knowledge... I'm new to moding
- Hey, I've moved this here because questions like this don't go in the "Main" namespace, so I'm going to delete the other article. Your personal Talk page is the more appropriate place for this kind of thing. Anyway, yes, this is exactly what GetSelf is for, so you should use that.
- One thing to remember (though you seem to understand this, I think) is that spell effect scripts run natively on the target (which is why GetSelf works in the first place; it returns the target instead of the spell because the game runs the script on the target). This means that you don't always need to use GetSelf (and often shouldn't). MoveTo is a perfect example of when you do need to use it, but it's a common mistake to over use it. As some examples, here's the basics of the script you want:
ref target Begin ScriptEffectStart set target to GetSelf itemRef.MoveTo target End
- vs. a script that moves the target somewhere else, like so:
ref target Begin ScriptEffectStart set target to GetSelf target.MoveTo itemRef End
- This second script I've written is "wrong" - it will work fine, but you don't need that ref variable and you don't need to call GetSelf. Doing so is redundant, and is less efficient than the script needs to be. Efficiency is very rarely a major concern in Oblivion scripting, but one should always avoid wasting processing when you don't have to. The second script above does the same as this (better) script:
Begin ScriptEffectStart MoveTo itemRef End
- Here, MoveTo isn't given a reference with the dot operator, so it will instead use the reference running the script - which in this case is the target of the spell, thereby achieving the same effect as the second script above, but saving memory and time by not using the ref variable or calling GetSelf needlessly.
- So, in conclusion, for the script you requested, you need to use GetSelf and that's the correct thing to do. For a sort of opposite script, you wouldn't need to use it at all, and doing so is just wasteful. Since you'll usually want to move things to the target, it's pretty common to use GetSelf with MoveTo, but plenty of other functions don't need GetSelf at all. You only need GetSelf when you must pass the target of the spell as an argument (that is, after the function, rather than before the dot).
- Hope that helps!
- Dragoon Wraith TALK 21:50, 1 January 2011 (EST)