Prototypes and Api Classes
When writing scripts, there are two essential API components that can be used in Kolben:
- Api Classes
- Prototypes
Api Classes
The simpler of the two are called Api Classes.They only offer standard static functions, getters and setters.
To use an Api Class, an import statement has to be used before using the Api Class itself.
An example for importing an Api Class for usage might look like this:
import TextBox from "Text";
This import statement contains two elements, the first (TextBox) sets the alias used within the script for this Api Class, the second (Text) where to import from.
The alias can be chosen freely, the source has to be exactly as defined in the game.
Example usage of the above import statement:
TextBox.show("Hello, World!");
A major advantage of Api Classes over Prototypes is that they can block script execution for user input.
In the above example, the script execution pauses until the textbox has been closed by the user.
No further script code is required to achieve this functionality.
Prototypes
The more complex of the two is called Prototype.Kolben is based on a Prototype-based object oriented class system. All built in types like string are also built using Prototypes.
At the first script execution by the game, the Kolben engine gathers all prototypes provided by the game and loads them to be used in every script, no importing required.
Each Prototype provided by the game has its own section in this documentation and describes how to use its various features.