AngelScript

from Wikipedia, the free encyclopedia
AngelScript
Aslogo.png
Basic data
Paradigms : object-oriented
imperative
structured
functional
Publishing year: 2003
Developer: Andreas Jönsson
Current  version 2.34.0   (September 22, 2019)
Typing : static
Influenced by: C , C ++
Operating system : platform independent
License : zlib license
angelcode.com/angelscript

AngelScript (short AS ) is a scripting language that is strongly based on C ++ . It was specially designed as an extension for C and C ++ programs and is mainly used in computer games and their underlying engines . AngelScript programs can be integrated into C ++ programs via the AngelScript programming interface (API). AngelScript is open source , is distributed under the free zlib license and is compatible with many operating systems and compilers .

language

Since AngelScript is specially designed for use with C ++, it is strongly oriented towards it. AngelScript supports the same elementary data types ( int , bool , ...), is object-oriented and uses almost the same syntax as C ++. However, there are also some differences from C ++:

  • The pointer operator * from C ++ does not exist, instead there is the @ operator, which works in a similar way
  • only public and private as access modifiers (additionally protected in C ++ )
  • Classes can only inherit from one base class (in C ++ from any number)
  • Class functions are automatically virtual (in C ++ this must be marked explicitly)

AngelScript source code is usually stored in .as files. The following sample source code shows an example of a simple .as file.

//Datei "beispiel.as"

void main()
{
    //Variablendeklarationen, -initialisationen und -operationen wie in C++
    int a = 5;
    ++a;
    int b = a + 3;

    if(b == 9)
    {
        /* wurde die Funktion print(string) vorher im C++-Quelltext registriert,
         * so wird sie jetzt aus AS heraus aufgerufen
         */
        print("Hello world\n");
    }
}

use

AngelScript is used 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 ++ source code is done by “registering” the C ++ functions and classes with the AngelScript engine. The following sample source code gives an example for registering a class Auto with its methods start () and brake () .

//Datei beispiel.cpp

#include "angelscript.h"

class Auto
{
    public:
        void starten(){};
        void bremsen(){};
};

int main()
{
    asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);

    engine->RegisterObjectType("Auto", 0, asOBJ_REF);

    engine->RegisterObjectMethod("Auto", "void starten()", asMETHOD(Auto,starten), asCALL_THISCALL);
    engine->RegisterObjectMethod("Auto", "void bremsen()", asMETHOD(Auto,bremsen), asCALL_THISCALL);

    return 0;
}

Global functions can also be registered in a similar way.

development

New versions with bug fixes and new functions appear at irregular intervals. Since the source code is freely accessible, the list of developers includes the main programmer as well as many volunteers who have participated in the development and improvement of the language and API.

Web links

Individual evidence

  1. List of all developers
  2. Incomplete list of software using AngelScript
  3. ^ AngelScript Changes. AngelCode.com, accessed December 28, 2018 .