Script

From X-Wiki

Jump to: navigation, search

A script is quite simply a set of instructions that tells the X2/3 Scripting Engine what actions to perform with or upon what objects (e.g., ships, stations, etc.) in the game, or modifies certain game properties. In addition, a script potentially manages the data used by itself and/or other scripts (e.g., assigning to or retrieving from local variables or global variables), which allows scripts to implement dynamic tasks that aren't restricted by the inflexibilities of only passing script arguments. A set of scripts that collectively add some desired functionality (or otherwise modify game behavior) is referred to as a plugin.

There are (nominally) three kinds of script, each addressing a different aspect or area of game modification:

General scripts. The most common variety (from the scripter's perspective), used to implement the various processes required for the execution of a task. This slightly modifies the MSCI Programmers Handbook's description of the relationship between processes and tasks and how they are treated by the Scripting Engine, but is (semantically) more intuitive for the small cost of accuracy and easily rectified later.

AL (Artificial Life) plugin scripts. The "under the hood" variety of scripts. As the term "Artificial Life" suggests, AL scripts give life to the X Universe. They run behind every NPC ship and control every spontaneous event in the game, from NPC ships that pass through sector trade lanes and make sales/purchases at a station to a random incursion by the Kha'ak. AL scripts are ideal for monitoring for specific changes in the state of the X Universe and initiating some action or event in response, which in conjunction with timers (every Event Handler Script defines a timer) is an excellent way to rig custom sequences of events. AL plugins are composed of a Registration Script, an Event Handler Script, and a Timer Handler Script.

Command scripts. These scripts link certain wares (i.e., software upgrades) to the custom functions and behaviors that are often provided by general scripts. A good example of this is the "Gunnery Crew" samples found in the MSCI Programmers Handbook. A command script can be thought of as the polar opposite of an AL script: Command scripts enable functionality controlled (i.e., switched on/off) by the player, while AL plugin scripts are controlled by timers defined by the scripter.

Scripts can also be used to rig custom event-sequences, or "quests". There are several examples in the Egosoft forums [1] of scripts being used to create optional side missions accessible from a station Bulletin Board System (BBS).


Links: [1]: http://forum.egosoft.com/viewforum.php?f=66

Personal tools
sections