Types
CES uses typed variables.
Each variable must declare a type before its name.
Syntax
The type is declared before the variable name.
Available Types
| Type | Description |
|---|---|
Int |
Integer numbers |
Float |
Decimal numbers |
Str |
Text values |
Bool |
Boolean values |
Inst |
Object instances |
Hex |
value of Color |
List |
Ordered collection of values |
Dict |
Key-value collection |
Int
The Int type stores whole numbers.
Output:
Float
The Float type stores decimal numbers.
Output:
Str
The Str type stores text.
Output:
Hex
The Hex type stores color.
Output:
Bool
The Bool type stores true or false.
Output:
Inst
The Inst type stores an object created from a class.
Output:
List
The List type stores multiple values in order.
Example
List friends : ["Paulo", "Pedro", "João"];
DisplayLog(friends[0]);
DisplayLog(friends[1]);
DisplayLog(friends[2]);
Output:
Nested Lists
Output:
Count Property
Output:
Dict
The Dict type stores key-value pairs.
Example
Output:
Nested Values
Output:
Count Property
Output:
Complete Example
Str player : "Lucena";
Int score : 250;
Bool alive : true;
Hex tractor_color: #0F0;
List inventory : ["book", "shield", "potion"];
Dict stats : { "hp" : 100, "mana" : 50 };
DisplayLog("Name: " + player);
DisplayLog("___________________________");
DisplayLog("score: " + score);
DisplayLog("___________________________");
DisplayLog("alive: " + alive);
DisplayLog("___________________________");
DisplayLog("tractor_color: " + tractor_color);
DisplayLog("___________________________");
DisplayLog("current item: " + inventory[0]);
DisplayLog("___________________________");
DisplayLog("hp: " + stats["hp"]);
DisplayLog("_______inventory_______");
for(Int i : 0; i < inventory.count; i += 1){
DisplayLog("--------------------");
DisplayLog(inventory[i]);
}
DisplayLog("___________________________");
Output:
Name: Lucena
___________________________
score: 250
___________________________
alive active: True
___________________________
tractor_color: #ff00ff00
___________________________
current item: book
___________________________
hp: 100
_______inventory_______
--------------------
book
--------------------
shield
--------------------
potion
___________________________
Name: Lucena
___________________________
score: 250
___________________________
alive active: True
___________________________
tractor_color: #ff00ff00
___________________________
current item: book
___________________________
hp: 100
_______inventory_______
--------------------
book
--------------------
shield
--------------------
potion
___________________________
Notes
Note
Type names are case-sensitive.
Use Int, not int.