Difference between revisions of "GetNthSummon"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Kyoma
(New page: __NOTOC__ A User Function for use with Oblivion Script Extender '''Syntax:''' (summon:ref) reference.Call GetNthSummon whichSummon:short Retu...)
 
imported>Kyoma
m (Added GetSummoner link)
 
(3 intermediate revisions by the same user not shown)
Line 4: Line 4:
'''Syntax:'''
'''Syntax:'''
  (summon:ref) reference.Call GetNthSummon whichSummon:short
  (summon:ref) reference.Call GetNthSummon whichSummon:short
Returns a reference to the nth actor currently summoned by the calling actor.  
Returns a reference to the nth actor currently summoned by the calling actor.  


==Notes==
==Notes==
*This function must be called on a reference (Ref.call <function>)  
*This function must be called on a reference (Ref.call <function>)  


==Examples:==
==Examples:==


Getting the number of summons active on a reference (in this case the player)
Getting a reference to a summon active on a reference (in this case the player)
  Let rSummon := player.Call GetNthSummon 0
  Let rSummon := player.Call GetNthSummon 0
  Let rSummon := player.Call GetNthSummon 1
  Let rSummon := player.Call GetNthSummon 1
  . . .
  . . .
  Let rSummon := player.Call GetNthSummon ''Nth''
  Let rSummon := player.Call GetNthSummon ''Nth''


==Code==
==Code==
Line 43: Line 39:
   let arFollowers := ar_Null
   let arFollowers := ar_Null
   End  
   End  
 
Alternative code for use with [[GetSummons]] (to avoid duplicate code)
ScriptName GetNthSummon
long iNth
array_var arSummons
Begin Function {iNth}
let arSummons := Call GetSummons
if TestExpr arSummons[iNth]
SetFunctionValue arSummons[iNth]
endif
let arSummons := ar_Null
End


==See Also==  
==See Also==  
* [[User Functions]]
* [[User Functions]]
* [[GetNumSummons]]
* [[GetNumSummons]]
* [[GetSummons]]
* [[GetSummoner]]
[[Category: User Functions]]
[[Category: User Functions]]


<!-- Begin Search Terms
<!-- Begin Search Terms
Summons
Summon
End Search Terms -->
End Search Terms -->

Latest revision as of 06:55, 26 December 2009

A User Function for use with Oblivion Script Extender

Syntax:

(summon:ref) reference.Call GetNthSummon whichSummon:short

Returns a reference to the nth actor currently summoned by the calling actor.

Notes[edit | edit source]

  • This function must be called on a reference (Ref.call <function>)

Examples:[edit | edit source]

Getting a reference to a summon active on a reference (in this case the player)

Let rSummon := player.Call GetNthSummon 0
Let rSummon := player.Call GetNthSummon 1
. . .
Let rSummon := player.Call GetNthSummon Nth

Code[edit | edit source]

ScriptName GetNthSummon
long iNth
array_var arFollowers
ref rFollower
long iFollower

Begin Function {iNth}
	let arFollowers := GetFollowers
	let iFollower := GetNumFollowers
 	While iFollower > 0
		let iFollower -= 1
		let rFollower := GetNthFollower iFollower
		ar_Erase arFollowers ( ar_Find rFollower arFollowers )
	Loop

	if TestExpr arFollowers[iNth]
		SetFunctionValue arFollowers[iNth]
	endif
 	let arFollowers := ar_Null
 End 

Alternative code for use with GetSummons (to avoid duplicate code)

ScriptName GetNthSummon
long iNth
array_var arSummons

Begin Function {iNth}
	let arSummons := Call GetSummons
	if TestExpr arSummons[iNth]
		SetFunctionValue arSummons[iNth]
	endif
	let arSummons := ar_Null
End 

See Also[edit | edit source]