AngelScript

Angel Script ( short AS) is a scripting language which is strongly oriented to C . It was designed specifically as an extension to C and C programs and is mainly used in computer games or their underlying engines. The programming interface ( API) that is needed to integrate AngelScript in existing software projects is open source, is distributed under the free zlib license and is compatible with many operating systems and compilers.

Language

Since AngelScript is specifically designed for use with C , it is strongly oriented towards it. To support AngelScript the same elementary data types (int, bool, ...) is object-oriented and uses an almost identical syntax as C . However, there are also some differences between C :

  • The pointer operator * from C does not exist, instead there is the @ operator, which works similarly but
  • Only public and private access modifiers as (in C additionally protected)
  • Classes can inherit from only one base class (in C of an arbitrary number )
  • Class functions are automatically virtual ( in C this needs to be explicitly marked )

Angel Script source code is usually stored in. As files. An example of a simple. As file shows the following sample code.

/ / File " beispiel.as "   void main () {      / / Variable declarations, initialisationen and operations as in C      int a = 5;      a;      int b = a 3;        if ( b == 9)      {          / * The function print ( string) has been previously registered in the C source code,           * As it is now called from AS out           * /          print (" Hello world \ n");      } } use

Is used AngelScript in many computer games, including Amnesia: The Dark Descent, the penumbra series, Warsow, Warhammer: Mark of Chaos and many other large and small projects.

The integration into existing C code is done by " registration" of the C functions and classes at the Angel script engine. The following sample code is an example of registering a car class with its methods start () and slow ().

/ / File beispiel.cpp   # include " angelscript.h "   class car {      public:          void start () {};          void brake () {}; };   int main () {      asIScriptEngine * engine = asCreateScriptEngine ( ANGELSCRIPT_VERSION );        engine- > register ObjectType ("Auto ", 0, asOBJ_REF );        engine- > Tab Object Method ("Auto", "void start ()", asMETHOD ( car start ), asCALL_THISCALL );      engine- > Tab Object Method ("Auto", "void brake () ," asMETHOD (car, brakes ), asCALL_THISCALL );        return 0; } Similarly, also global functions to register.

Development

AngelScript is in constant development. At intervals of one to three months, updated versions appear with bug fixes and new features. Since the source code is freely available, the list of developers, along with the main programmer many volunteers who have participated in the development and improvement of the language and the API.

64683
de