ChaiScript Overview

ChaiScript is an embedded scripting language designed for C++. You can use ChaiScript to expand the functionality of RealmJoin. Use the following script examples and the scripts in the GK Script Objects section to learn how to customize your RealMigrator.

To download ChaiScript click the following link: http://chaiscript.com

Variables

var i; // uninitialized variable, can take any value on first assignment;

var k = 5; // initialized to 5 (integer)
var &m = k; // reference to k

Built in Types

var i = 1; // creates an integer
var u = 1u; // creates an unsigned integer
var s = "hello"; // create a string
var f = 1.0; // creates a float

var v = [1,2,3u,4ll,"16", `+`]; // creates vector of heterogenous values
var m = ["a":1, "b":2]; // map of string:value pairs

Working with strings

Conditionals

Loops

Each of the loop styles can be broken using the break statement. For example:

Functions

Optionally Typed

Classes/Objects

Class definition

Working with class objects

JSON

Script
Function

from_json

Converts a JSON string into its strongly typed (map, vector, int, double, string) representations

to_json

Converts a ChaiScript object (either a object or one of map, vector, int, double, string) tree into its JSON string representation

Last updated

Was this helpful?