Difference between revisions of "OnDistanceGreaterThan - ScriptObject"
Jump to navigation
Jump to search
imported>Plplecuyer (Created page with "Category:Scripting Category:Papyrus Category:Events '''Member of:''' ScriptObject Event called when two objects are farther then the register...") |
imported>Docclox m (→Example: afDistance value was missing in the event registration) |
||
Line 21: | Line 21: | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Function SomeFunction() | Function SomeFunction() | ||
RegisterForDistanceGreaterThanEvent(Game.GetPlayer(), Bird) ; Before we can use OnDistanceGreaterThan we must register. | RegisterForDistanceGreaterThanEvent(Game.GetPlayer(), Bird, 1000.0) ; Before we can use OnDistanceGreaterThan we must register. | ||
EndFunction | EndFunction | ||
Latest revision as of 09:17, 24 August 2016
Member of: ScriptObject
Event called when two objects are farther then the registered distance apart - if this script is registered for it.
This event will only be sent to the specific script that registered for it. Other scripts attached to the same form/alias/active magic effect will not receive the event unless they also register.
Syntax[edit | edit source]
Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
Parameters[edit | edit source]
- akObj1: The first ObjectReference which the distance check was performed on.
- akObj2: The second ObjectReference which the distance check was performed on.
- afDistance: The exact distance between the two objects at the time the event fired.
Example[edit | edit source]
Function SomeFunction()
RegisterForDistanceGreaterThanEvent(Game.GetPlayer(), Bird, 1000.0) ; Before we can use OnDistanceGreaterThan we must register.
EndFunction
Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
;/ If other registrations had been done, we would want to check the objects
But since we only registered for one we know what it is /;
Debug.Trace("Player is now " + afDistance + " units away from the bird - let's land")
endEvent
Notes[edit | edit source]
- The two objects are interchangeable. They always match the order they were registered in, assuming someone else didn't register with the opposite order first.
- Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.