Difference between revisions of "TryToEnable - ReferenceAlias"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Scornett
m (Reverted edits by Scornett-Bot (talk) to last revision by Jlundin)
 
imported>Thingy Person
 
Line 9: Line 9:
<source lang="papyrus">
<source lang="papyrus">
bool Function TryToEnable()
bool Function TryToEnable()
ObjectReference Ref = GetReference()
if Ref
Ref.Enable()
Return True
EndIf
Return False
EndFunction
</source>
</source>



Latest revision as of 16:25, 29 June 2013

Member of: ReferenceAlias Script

This is a convenient way to enable a reference in an alias without calling GetReference() on it. It's mostly useful in cases where you have lots of aliases that may or may not be filled and you want to call Enable() on them without having to test for a reference being present first.

Syntax[edit | edit source]

bool Function TryToEnable()
	ObjectReference Ref = GetReference()
	if Ref
		Ref.Enable()
		Return True
	EndIf
	Return False
EndFunction

Parameters[edit | edit source]

None

Return Value[edit | edit source]

True if the reference was enabled, false if there was no reference to enable

Examples[edit | edit source]

; Enable the cool object
if CoolAlias.TryToEnable()
  Debug.Trace("Cool object enabled!")
else
  Debug.Trace("No cool object exists...")
endIf

See Also[edit | edit source]