Events Reference: Difference between revisions

Jump to navigation Jump to search
m
Convert source tags to syntaxhighlight
(Unprofessional writing)
m (Convert source tags to syntaxhighlight)
 
Line 17: Line 17:


=== Examples ===
=== Examples ===
<source lang="papyrus">
<syntaxhighlight lang="papyrus">
; A simple activate event handler  
; A simple activate event handler  
Event OnActivate(ObjectReference akActivator)
Event OnActivate(ObjectReference akActivator)
   PlayAnimation("CoolStuff")
   PlayAnimation("CoolStuff")
endEvent
endEvent
</source>
</syntaxhighlight>


== Special Variables ==
== Special Variables ==
Line 36: Line 36:


For example:
For example:
<source lang="papyrus">
<syntaxhighlight lang="papyrus">
  Event OnHit(ObjectReference akAggressor, Form akWeapon, Projectile akProjectile)
  Event OnHit(ObjectReference akAggressor, Form akWeapon, Projectile akProjectile)
   
   
  EndEvent
  EndEvent
</source>
</syntaxhighlight>
You might be tempted to try something like this:
You might be tempted to try something like this:


<source lang="papyrus">
<syntaxhighlight lang="papyrus">
Event OnHit(Game.GetPlayer())
Event OnHit(Game.GetPlayer())
  ;do something
  ;do something
EndEvent
EndEvent
</source>
</syntaxhighlight>
'''However, that does NOT work.'''
'''However, that does NOT work.'''


Instead what you need to do is something like this:
Instead what you need to do is something like this:
<source lang="papyrus">
<syntaxhighlight lang="papyrus">
  Event OnHit(ObjectReference akAggressor, Form akWeapon, Projectile akProjectile)
  Event OnHit(ObjectReference akAggressor, Form akWeapon, Projectile akProjectile)
  if akAggressor != game.getPlayer()
  if akAggressor != game.getPlayer()
Line 58: Line 58:
;do something
;do something
  EndEvent
  EndEvent
</source>
</syntaxhighlight>


== See Also ==
== See Also ==

Navigation menu