|To Getting Started|
Triggers are are a way to set up a reaction to some action or event in the game. If a player dies, that is an event or if a player clicks on a certain block that is an action and we can setup a reaction to these with triggers.
Triggers are set with in-game commands like /vtclick and /vtevent you add lines of script to the trigger with these same commands. Triggers are saved in the trigger files located in the /plugins/VariableTriggers/ folder. Each trigger type has its own file as in WalkTriggers.yml and EventTriggers.yml and so on..
Below is a list of the different trigger types.
Triggers that are based on a block Location
|Click||This is activated when a player clicks a block, any block, at a location.|
|Walk||This is activated when a player walks on a block, any block, at a location.|
To set a click trigger or add script to an existing click trigger you use /vtclick [Line of script]
To set a walk trigger or add script to an existing walk trigger you use /vtwalk [Line of script]
Create triggers that run script when a player types a /command. You can make some extra things happen when players type commands like /heal or you can create your very own commands like /foobar or /setquest
See In-Game Commands for a list of commands to create the triggers.
You can set two locations to create an area cube and set triggers on it.
|Enter||This is triggered when player enters the area and runs the attached script.|
|Exit||This is triggered when player exits the area and runs the attached script.|
To set an area trigger you first need to define an area. You do this by typing /vt setarea and then use the wand to Left click for possition 1 and Right click for possition 2. Once the two locations are set type
/vt definearea [AreaName]
To set a trigger on an area or add script to an existing trigger you use
/vtarea [AreaName] [Enter|Exit] [Line of script]
A few words about areas and how they work and remember areas ar 3D cubes so you must also set the height.
Triggers that are Event based. So far i have added these:
|PlayerDeath||This is triggered when a Player dies for whatever reason. The normal placeholders refer to this player.|
|EntityDeath||This is triggered when an Entity(other than a player) is killed by a player. The normal placeholders refer to the killing player. <triggerloc> refers to the location of the entity on death.|
|BlockBreak||This is triggered when a block is broken. The normal placeholders refer to the player . <triggerloc> refers to the location of the broken block.|
|BlockPlaced||This is triggered when a block is placed. The normal placeholders refer to the player . <triggerloc> refers to the location of the placed block.|
|Respawn||This is triggerd when a player respawns after dying. <triggerloc> is the respawn location of player.|
|Join||This is triggerd when a player joins the server. <triggerloc> is the player's location|
|Quit||This is triggerd when a player quits the server. <triggerloc> is the player's location. Remember you can't do anything to the player like @TP or <currentloc:> as they have logged out and are no longer in play.|
|Interact||This is triggerd when a player right clicks on an entity. <triggerloc> is the location of the clicked entity. Entity can be a Player, Mob or Animal. NPC plugins such as Citizens return type PLAYER so you can use their name to determine what NPC is being interacted with.|
|EntitySpawn||This is triggerd when an entity is spawned. <triggerloc> is the spawn location of the entity. Entity can be a Mob or Animal. This event is usually called A LOT(20 times a second) so keep your scripts small or use IF test and only do something under certain conditions.|
|Chat||This is triggered when a player types in the chat window. The normal placeholders refer to this player and ther are a few specific to this event. <chatline> <chatwordcount> and <chatword:index>. See Functional Place Holders and Place Holders specific to Chat event.|
|Timer||The timer will exicute any script attached to it once every minute. It is up to you to set and test your variables to decide how often to allow exicution.|
|Usage: /vtevent Timer [SCRIPTLINE]|
|One important thing to remember is that this is not triggered by a player and therefore the normal place holders are not valid. <playername> will be 'null' and <playerloc> will be 0,0,0 <health> will be 0 and so on. You may use Functional Place Holders that let you set a player name and must get it from object variables you have saved. You may not use @PLAYER as it asumes the triggering player but you may use @BROADCAST or @TELL|
To set an event trigger or add script to an existing event you use
/vtevent [EventName] [Line of script]
BlockBreak and BlockPlaced Events are not called if any other block protection has cancelled it. This should be true with most severs but depending on the plugins you use it may still be cancelled after the script is called so if you experiance your scripts running even though the event was cancelled you need to test for this in your script if you only want your script to run if the event was not cancelled. Since VariableTriggers Script Interpreter runs on its own thread it starts running the script faster than the other plugins have a chance to cancel the event so start your script for these two events with a pause and test like so:
- '// Pause 1/4 second' - '@PAUSE 0.25' - '// Test to see if block was is still there' - '@IF <isblocktype:<triggerloc>:<blocktype>> = false' - '// Break was succesfull so continue with script'
- '// Pause 1/4 second' - '@PAUSE 0.25' - '// Test to see if block was is still there' - '@IF <isblocktype:<triggerloc>:<blocktype>> = true' - '// Place was succesfull so continue with script'
|To Getting Started|