Tutorial of X-Script
Updated: 12.08.2007
Last comparison with original (german) version: 05.12.2007
Master coordinator Nathanael alias Natter
In this chapter, the basic elements of X-script are explained. This category contains program name, the procedure StartMission, and the mission name.
In this chapter beside others the elements Constants and simple Message boxes are treated.
Introducing Missiontypes. Furthermore, it is shown how to configure events leading to defeat and victory.
It is shown how to create UFOs. Furthermore, some new language elements are introduced, including variables, the function random(n) in order to create random numbers, arithmetic operations, and the for...to-loop.
Shows how to control victory or defeat in connection with register_ufo_* and event_register(...). With these, UFOs can be defined as victory conditions and procedures can be called after a certain tim.
Will be completed, as soon as X-script will contain the appropriate functions (propably version 0.850 (?!?)).
The most important attributes and methods which are available for TUFO are explained. Furthermore the type boolean is introduced and the correct usage of the conditional instruction if...then is explained. In addition, hints in order to avoid problems with globally defined variables are given.
The complete script for chapter 3 is given. In addition, trouble shooting assistance provided by the script editor itself is presented.
How to format strings and message windows.
ASCII symbols in strings; Tags for coloured text; mzUser; Declarations with forward
The 1. quiz is constructed. For that purpose, TStringList and the corresponding methods Create, Add, CommaText and Free are introduced. In addition, informations concerning the handling of object variables are provided. game_api_ChooseItemBox is introduced, as well as the loop while ... do and the commands Inc and StrToInt.
The 2. quiz is constructed. The method TStringList.Count, the operator not, the function game_api_QueryText and the procedure (Ansi)UpperCase are introduced.
The 3. quiz is constructed. Placeholder in strings, the appropriate function 'Format and StrtoIntdef are introduced.
savegame_api_FreeCredits; savegame_api_GetCredits, savegame_api_NeedCredits, game_api_GameOver, IntToStr
savegame_api_Message and a bunch of other commands used to manipulate strings.
In this chapter, it is shown how one can handle different languages with DEFINE.
TEinsatz (including the methods AddAlien and Start); TAlien; einsatz_api_generateeinsatz; alien_api_GetRandomAlien
country_api_count; country_api_getCountry; country_api_GetRandomLandPosition; TCountry.Name; TEinsatz.Position; TEinsatz.Name; TEinsatz.Description; TEinsatz.Objectives; TEinsatz.RemainTime; TEinsatz.MapName; break; array of; SetLength; high; einsatz_api_getMapFiles; TAlien.Ges
EVENT_ONEINSATZTIMEUP; EVENT_ONEINSATZWIN
TEinsatz.PopulateFromUFO; LongWord; function; alien_api_GetCount; alien_api_GetAlienByIndex; TAlien.Name; string_utils_split; "Conversion" of TObject-variables; var; record; type; set of; include; Arithmetic and logical operators
Appendix A - Tasks
This part contains tasks to most of the chapters, with which you can check and deepen your knowledge.
Here, some solution suggestions for the particluar tasks are collected.
The following articles are taken over from Delphi-Source by a great deal and are adapted to X-Script. X-Script is based on Pascal Script, so if you know Pascal (or Delphi), you should feel at home.
Appendix C - Independant chapters
[Here you find chapters, which do concern X-Script, but were not written for the tutorial itself.]
This chapter describes, in which sequence special functions and events are called within a script.
This chapter discusses the different possibilities, to control and call multiple used functions.
This chapter describes what should be considered while naming functions and variables.
Miscellaneous