Difference between revisions of "OnTrigger"
Jump to navigation
Jump to search
imported>Antares (Adding OnTriggerActor to the See Also section, pretty funny that it hasn't been done until now.) |
imported>Aellis m (added triggerzone explanation) |
||
Line 5: | Line 5: | ||
begin OnTrigger player | begin OnTrigger player | ||
This block will be run | This block will be run when something triggers the scripted object by colliding with it. If you specify a TriggeringRefID, the block will only run when that specific reference triggers the object; otherwise, the block will run when anything triggers the scripted object. | ||
With a Triggerzone however, unless you specify a variable to keep track of if the zone is triggered, the block will continue running (looping) until the triggering ref leaves the zone. Once the ref leaves the zone, the zone will not reset unless you include a reset block. The reset block can either be timed or reset when the cell respawns. | |||
'''TriggerZone Examples:''' | |||
'''Timed Reset''' | |||
short triggered | |||
float timer | |||
begin onTrigger | |||
if triggered == 0 | |||
'do something | |||
set triggered to 1 | |||
set timer to 2 ;2 delay before reset | |||
endif | |||
end | |||
begin gameMode | |||
if triggered == 1 && timer <= 0 | |||
set triggered to 0 | |||
endif | |||
if timer >= 0 | |||
set timer to timer - getSecondsPassed | |||
endif | |||
end | |||
'''Cell Respawn''' | |||
short triggered | |||
begin onTrigger | |||
if triggered == 0 | |||
'do something | |||
set triggered to 1 | |||
endif | |||
end | |||
begin onReset | |||
set triggered to 0 | |||
end | |||
==See Also== | ==See Also== |
Revision as of 13:40, 28 April 2009
Syntax:
begin OnTrigger TriggeringRefID
Example:
begin OnTrigger begin OnTrigger player
This block will be run when something triggers the scripted object by colliding with it. If you specify a TriggeringRefID, the block will only run when that specific reference triggers the object; otherwise, the block will run when anything triggers the scripted object.
With a Triggerzone however, unless you specify a variable to keep track of if the zone is triggered, the block will continue running (looping) until the triggering ref leaves the zone. Once the ref leaves the zone, the zone will not reset unless you include a reset block. The reset block can either be timed or reset when the cell respawns.
TriggerZone Examples:
Timed Reset
short triggered float timer begin onTrigger if triggered == 0 'do something set triggered to 1 set timer to 2 ;2 delay before reset endif end begin gameMode if triggered == 1 && timer <= 0 set triggered to 0 endif if timer >= 0 set timer to timer - getSecondsPassed endif end
Cell Respawn
short triggered begin onTrigger if triggered == 0 'do something set triggered to 1 endif end begin onReset set triggered to 0 end