Script
The file
- Every file holds one script; the extension is
.kalem, the encoding UTF-8. - The script's name is PascalCase and the file's name its kebab-case form:
BusinessHours↔business-hours.kalem. The compiler checks that they match. - The script's id comes from the file name:
kalem/business-hours. Components name the script by this id (Components).
The header
/// Opens and closes the business by its hours and the town's power.
server script BusinessHours extends Building
label "Business · opening hours"
category "Server behaviours"
version 2 // optional, 1 if omitted; used by migration
serverorclientis required: a script runs either in the world or on screen.extendsnames the script's host type: where it can be attached and what it can use (Host types). The host type must be on the script's side:Buildingis a server type,VisualEffecta client type.- A script extends exactly one host type; scripts do not extend each other.
labelandcategorytitle the script in the Add Component selector and on the component's card. The///comment above the header is its description.versionis 1 when omitted; raising it runson migratewhen a live world moves to the new definition (Saving and migration).
What the side allows
| Declaration | Server | Client |
|---|---|---|
property, group, function | yes | yes |
memory, reads, writes, timer | yes | no |
event handlers, state | yes | no |
input | no | yes |
Server code is never sent to the screen: the compiler puts only client scripts in the client's package.
Several scripts on one object
A package, a part or the world can take several scripts. Their order is the order of the components in the editor, and it also sets the order of work within a minute.
What a script declares
After the header, in any order:
| Declaration | Page |
|---|---|
property, group | Properties |
memory | Memory and locals |
reads, writes | Contract fields |
on … | Events |
timer | Timers |
state, auto state | States |
function | Functions and expressions |
input | Client scripts |