Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/Trigger


Ignore:
Timestamp:
Nov 12, 2008, 11:09:34 PM (16 years ago)
Author:
bknecht
Comment:

Added documentation for trigger. Maybe something changed, please check if everything is correct. TODO Event trigger description

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/Trigger

    v1 v1  
     1= Trigger =
     2[[TracNav(TracNav/TOC_Development)]]
     3[[TOC]]
     4''This documentation refers to revision r2200 be aware that some things may have changed if your revision number differs too much.''
     5
     6Triggers are objects which react on certain events. You can combine triggers to use them as simple overlay logic in the levels. All triggers inherit from their main class Trigger and each implement a special functionality. The main class has no special functionality.
     7
     8If a trigger gets triggered it will change its state from active to inactive or the other way around. Triggers can be combined in a tree structure with a well defined parent-child relationship. You will be able to tell the parent who it should react on state changes from its children.
     9
     10At the beginning the Trigger is not triggered and not active.
     11
     12== Basic Functionality ==
     13
     14Following functionality is implemented in the main class and therefore usable by all triggers.
     15
     16=== XML Port ===
     17All triggers can be added into the level file. They can be nested like the XML-tags you know already. This will look like this for example:
     18
     19{{{
     20<Trigger position="0,200,0" scale="2" delay="2">
     21  <DistanceTrigger position="100,0,0" scale="2" distance="80">
     22  <DistanceTrigger position="150,0,0" scale="2" distance="80">
     23</Trigger>
     24}}}
     25
     26You may noticed that it doesn't matter what kind of trigger is nested. The two DistanceTriggers are children of the Trigger object. Also note that position and scale are inherited properties of WorldEntity.
     27
     28=== Number of Activations ===
     29A trigger may have a limited number of activations. This option overrules any other option which would hinder the trigger to be activated that many times. This means that the Stay Active-option cannot be used with a limited number of activations. The default value is -1 meaning that the number of activations is unlimited.
     30
     31Set the number of activations in the level file by using the parameter ''activations="5"''.
     32
     33=== Stay Active ===
     34Once the trigger is active it cannot be deactivated anymore. This option is overruled by the Number of Activations-option.
     35
     36Use the parameter ''stayactive'' to turn this option on. This is turned off by default.
     37
     38=== Switch ===
     39If a trigger is a switch it only changes its state when it is triggered, but not when it is un-triggered. Without the Switch-option the trigger is only active during the time it is triggered. With the Switch-option turned on the trigger stays active until the next time it is triggered.
     40Imagine pressing a light switch. The lamp will be lit even after you released your finger from the light switch. To turn it of you have to press (trigger) the switch a second time.
     41
     42To turn on this property use ''switch'' in the level file. It is turned off by default.
     43
     44=== Delay ===
     45Introduces a delay until the trigger reacts. Inside the trigger there is a FIFO queue which stores state changes. If a delay is set, each state change will wait for the chosen time until it will leave the queue and changes the state of the trigger.
     46You can alter the delay at runtime. However a state change which occurred before the alteration of the delay will wait the amount of time which was set when it entered the queue. It is also not possible to put a state change somewhere between waiting states by changing the delay, because the queue is a FIFO queue. Trying to do that will result in two state changes at the same time.
     47
     48Set the delay by using ''delay="2.3"'' in the Trigger tag (the value is the delay in seconds). Default is ''0''.
     49
     50=== Mode ===
     51This mode refers to how the trigger should behave when its children are becoming active. There are three different modes:
     52
     53==== AND ====
     54The trigger is only activated when all children are active and the trigger is also triggered by its special functionality.
     55
     56==== OR ====
     57The trigger is activated when any child is active or it is triggered by its special functionality.
     58
     59==== XOR ====
     60The trigger is only activated when there is only one child active or it is only triggered by its special functionality.
     61
     62Set the modes using ''mode'' in the level file (use lower case). Default value is ''and''.
     63
     64=== Invert ===
     65This option inverts the mode to NAND, NOR or XNOR.
     66
     67Use ''invert'' to invert the mode. This is turned off by default.
     68
     69== Distance Trigger ==
     70A distance trigger is triggered when certain objects are in its vicinity.
     71
     72=== Distance ===
     73The maximum distance between a certain object and the trigger so it is still triggered.
     74
     75Set the distance in the level file using parameter ''distance="50"''. Default distance is ''100'' units.
     76
     77=== Targets ===
     78You have two possibilities to set the target of the distance trigger. Specify a [wiki:Identifier class name] and the distance trigger will react on every object which belongs to this class either directly of inherited. This is established by using a ClassTreeMask.
     79
     80Just add an object to the trigger and the trigger will react on exactly this object and no other. This second possibility is however not supported fully and you shouldn't use it. In both cases you can change the targets by adding and removing them.
     81
     82To set the class name of targets use ''target="!BaseObject"''. Default is ''ControllableEntity''. Note that you cannot set the target to ''Trigger'' as this would result in the trigger triggering itself. Setting the target to ''Trigger'' will therefore be ignored.
     83
     84== Event Trigger ==
     85Coming soon...