Updated April 5, 2023
Introduction of AngelScript
AngelScript is defined as a game-oriented angel-code scripting language, which was developed by Andreas Jonsson as a cross-platform scripting library; it works by creating and running a virtual machine inside the computer, scripts in it are written by using c/c++ syntax, which allows us to write scripts, a computer program, that will work on any computer platform, it has features like static typing, object handles, object-orientation, single inheritance, multiple inheritances with interfaces, also allow to operators to be registered and overloaded, the virtual machine in it take care of the details such as memory management and pointers, it is free to use.
Why do we Need AngelScript?
AngelScript is needful because it is a powerful object-oriented scripting language like c/c++. It has an extremely flexible cross-platform scripting library; hence the scripts or a computer program written can work on any platform, and the scripting library is designed to improve the functionality of the script; by using it, users can extend the functionality with the help of external scripts.
It also has a feature that we can call the c and c++ functions within the angel-script environment; due to that, it is helpful to the developers to work with it, and the syntax of the angel-script class was closely followed by the syntax in c++ classes. So that it is needful for developers who are worked with c++ and they have to work on angel-script, then they can work easily.
Angelscript can be used in robotics that means the behavior rules of robotic are followed by angel-script. Also, it is useful for video game development, which increases the life of a game. So by using angle-script, get the project up, and that will run faster. And by using an external script, we can improve the functionality of the application.
How does AngelScript Work?
The working of Angelscript is as follows, as it has an embedded scripting library, the angel-script allows the script to work with them.
- First, we need the application of angel-script and then have to register the interface so that script can interact with the application; the interface contains functions, variables, and classes also.
- Secondly, we have to set message call back to receive information about errors, errors in human-readable form, because if the registration is not done correctly, then attention message will get as a callback message about the incorrect registration or a script has an error that fails to compile. If we need to verify the return code, there is no need to take much effort to know it because the call-back message can give information in the human-readable form so that we can correct it. These two steps are about engine configuration.
- After engine configuration next step is to compile the script that should be executed. Also, need to write a function to call the registered print function and will give the output that function is stored in files.
- In this step, has to write code for loading script files and to compile it, there is a CSriptbuilder define it, which help to load the file, it will perform some necessary process, and it will tell the engine to build a script module, also need to construct builder code for processing. If the code fails after this, then it will not have the memory to allocate the module. If the filename has been removed or the wrong name was given, or there is some unnecessary code has been written, then the builder was not able to load the file.
- The last step is to identify the function which was defined that is to be called and have to set up the context for execution in code format. If that function could not be found, then need to write a print function to show a message of the function expecting.
- Then has to create context, prepare it, and then execute it; if the execution didn’t work as expected, there is a need to write an exception code to handle the exception.
Example of AngelScript
Below is a very simple example that will give a brief overview of Handle:
system.out.println("List of student");
void CallHandle(Stu@ s)
Stu@ s= null;
@s = Stu();
Stu@ s1 = null;
if (s1 == null)
if(s1 is null)
if(s1 !is null)
In the above example, we explain the Handles concept, which is new in angel-script rather than c/c++; in that example, we take a class and create a method to call handles and then, in the main method called the function for student name, took a null reference of it and while handling we create two null references to handle the exception. This is the overview of Handles.
AngelScript is advantageous because of its features,
- It has features like c/c++ that is static-typing, that uses the same static type as we use in c/c++ to make typing dynamic, and only additional type that we need to register here in angel-script.
- It has an object handle feature that provides pointers, but pointers are not safe in scripting; hence it uses object handles instead of pointers; object handles in scripting control the lifetime of the object.
- It has mod support in-game logic where it increases the life of the game.
Some of the disadvantages are given below;
- Angelscript supports native calling conventions on major platforms, but there are some platforms that only work with generic calling conventions; generic calling is pure C++ that works everywhere.
- The CScriptString used in angel-script cannot return the object value in native mode, which is not compatible.
- There may be a memory leak issue.
In this article, we conclude that it is a scripting language and that has information about the application to accurately communicate with the c/c++ code; it has an inbuilt library hence making scripting language in our project is easy; in this article, we have seen some reasons to develop our program in more than one language.
This is a guide to AngelScript. Here we also discuss the introduction and why do we need angelscript? along with advantages and disadvantages. You may also have a look at the following articles to learn more –