User talk:Hammil

Active discussions

GetIsIDEdit

First, thank you so much for contributing to the Wiki! You're absolutely right, GetIsID player will not work. However, the workaround you offer is not ideal for a few reasons.

One, player in scripts secretly means playerRef. It's one of the few cases where you'd have to use the formID in a script, if you really needed to refer to the player base form, since the compiler always treats player as playerRef. Therefore, GetIsID player will never work - as you noted.

Two, you don't need to use GetSelf in this situation, and indeed shouldn't (wastes memory and processing time; minuscule amounts, true, but nonetheless). GetSelf is used only when you need to pass the target of a spell as an argument to a function, for example in this script:

set refVar to GetSelf
persistentActivator.MoveTo refVar

Using GetSelf makes perfect sense, since you can't use persistentActivator.MoveTo (GetSelf) as Oblivion does not support nested calls (without OBSE, anyway). However, since functions that run on a reference default to the reference running a script, using a temporary variable when using the dot-syntax is simply wasteful. These two scripts are functionally identical:

set refVar to GetSelf
if ( refVar.GetIsReference player )

and

if ( GetIsReference player )

The second merely avoids wasting time and memory on the temporary reference variable.

Third, and this is a minor point: generally, when testing a boolean (true/false) value, it's better not to use == 1. For one thing, "true" means != 0, which isn't necessarily the same as == 1 (it is in the case of functions that return boolean values, but there are other times to use boolean tests). For another, if ( boolean ) is identical to if ( boolean != 0 ), but is cleaner, easier to read and write, and executes marginally faster. Best practice is to use simply if ( boolean ), or in the case of your suggested script, if ( GetIsReference player ).

I hope that explains the situation!
Dragoon Wraith TALK 17:23, 9 September 2010 (EDT)

Return to the user page of "Hammil".