docs/Scripts

Scripts

To Getting Started

A script is nothing more that lines of text that are executed when a Trigger is activated by an Event or a player walking over a block or clicking on it depending on the type of trigger. Each script line can have one and only one script command followed by its parameters but you can add as many script lines to a trigger as you need. The trigger and script data are stored in YML format for easy access. All triggers and scripts are created in the game, there is no need to manually edit the YML files. If you happen to be one of those people that feel better with hands on scripting, and want to delve deep then be very careful when editing the YML file. NO TABS. ALL script lines MUST be enclosed in single quotes. ( ' ), and be sure to escape ( '' ) any single quotes you use in the line. Spacing is critical in the lines of script, do not double space between parameters or forget a space. This would throught an error when the yml file is loaded.

See a list of script commands

Scripts Save In Trigger Files

When you great a trigger or add a line of script to a trigger like this
/vtwalk @ENTITY ZOMBIE 1 <triggerloc>

the line of script is save in WalkTriggers.yml file as part of that trigger. Click trigger script lines are save on the trigger in the ClickTrigger.yml file and so on...

Separate Script Files

You can also save scripts in separate files filename.script.yml that are auto loaded at startup. VariableTriggers will search for files with .script.yml extension and load to memory for fast access from the interpreter. This in conjunction with the Functional Place Holder <relativeloc:arg1:arg2> will allow you to write reusable scripts relative to the Place Holders <triggerloc> or <playerloc>

To exicute these additional scripts you will use the script command:
@CALL [filename:script]
from within your scripts to run other scripts. for the filename argument do not use the extension. filename.script.yml

Example:

Say you have a script file named myscripts.script.yml and inside it you have two scripts named abc and TempleTP like so:

Scripts:
  abc:
    Script:
    - '@PLAYER Hello <playername>'
    - '@PLAYER I know my ABC''s. Wanna sing with me?'
  TempleTP:
    Script:
    - '@PLAYER Teleporting in 2 seconds.'
    - '@PAUSE 2'
    - '@TP $loc.temple'

You want to run the script TempleTP from this file so you would type this

/vtclick @CALL myscripts:TempleTP

or add this to a script by hand.

- '@CALL myscripts:TempleTP'

You may call as many scripts from within a script as needed as long as you dont call a depth greater than 20. In other words Calling a script from a scipt is a depth of 1 and if that script calls a script your at depth 2 and so on...

If you call a script that calls a script that calls a script ( depth 3) and that script ends so your back at depth 2 and call another script your only depth 3 again even though you have called a total of 4 scripts. Get it?

Be sure to visite http://dev.bukkit.org/server-mods/variabletriggers/forum/sharescripts/ and look through thes scripts to help get an understanding of the syntax.

To Getting Started