Difference between revisions of "MoveToIfUnloaded - ObjectReference"

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>Lisselli
m (→‎Examples: add notes on using this to move actors in sight of the player.)
 
(One intermediate revision by one other user not shown)
Line 8: Line 8:
== Syntax ==
== Syntax ==
<source lang="papyrus">
<source lang="papyrus">
bool Function MoveToIfUnloaded(ObjectReference akTarget, float afXOffset = 0.0, float afYOffset = 0.0, float afZOffset = 0.0)
bool function MoveToIfUnloaded(ObjectReference akTarget, float afXOffset = 0.0, float afYOffset = 0.0, float afZOffset = 0.0)
if !Is3DLoaded()
MoveTo(akTarget, afXOffset, afYOffset, afZOffset)
return true
else
return false
endif
endFunction
</source>
</source>


Line 37: Line 44:
endIf
endIf
</source>
</source>
== Notes ==
*Using this on actors in sight of the player, will cause the actors to uequip all their armor after the move is complete.


== See Also ==
== See Also ==
*[[ObjectReference Script]]
*[[ObjectReference Script]]

Latest revision as of 19:00, 20 November 2016

Member of: ObjectReference Script

Moves this reference to the location of the target reference, with the specified offset, if this reference is currently unloaded (has no 3D). If it is loaded, it does nothing.

Syntax[edit | edit source]

bool function MoveToIfUnloaded(ObjectReference akTarget, float afXOffset = 0.0, float afYOffset = 0.0, float afZOffset = 0.0)
	if !Is3DLoaded()
		MoveTo(akTarget, afXOffset, afYOffset, afZOffset)
		return true
	else
		return false
	endif
endFunction

Parameters[edit | edit source]

  • akTarget: The target reference to move this one to.
  • afXOffset: How much to offset the move in the X direction.
    • Default: 0.0
  • afYOffset: How much to offset the move in the Y direction.
    • Default: 0.0
  • afZOffset: How much to offset the move in the Z direction.
    • Default: 0.0

Return Value[edit | edit source]

True if the object was moved, false if not.

Examples[edit | edit source]

; Move the box to the shelf, but only if it is unloaded
if Box.MoveToIfUnloaded(Shelf)
  Debug.Trace("Moved the box")
endIf


; Move the box above the shelf, but only if it is unloaded
if Box.MoveToIfUnloaded(Shelf, 0.0, 0.0, 1.0)
  Debug.Trace("Moved the box above the shelf")
endIf

Notes[edit | edit source]

  • Using this on actors in sight of the player, will cause the actors to uequip all their armor after the move is complete.

See Also[edit | edit source]