Types

The kinds of value a script can produce and pass around.

Every value has exactly one type. There is no type declaration: a variable simply holds whatever value you put in it, and a binding may hold values of different types over its life. When an operation needs a specific type and gets something else, the script stops with a run-time type error — see Values for how types interact.

The type set

Type Holds
null the absence of a value
bool true or false
int a whole number, positive or negative
string a run of text
iterable an on-demand sequence (iterables)
block a callable piece of code (blocks)
list an iterable ordered group of values
creature a live mobile or player
object a live object instance
room a room
mob_proto a mobile prototype, by vnum
obj_proto an object prototype, by vnum

Scalar types

null

null means "no value." It comes from a side-effecting command (those return null), from recall of a slot that was never stored, from a block with an empty body, and from return with no argument. When converted to text it renders as the empty string. null is not a bool — testing it in a boolean context is an error (see Values).

bool

true and false. You get a bool from the literals, from the comparison and predicate builtins, and from the logic operators and / or / not. Boolean contexts (such as an if condition or a guard) require a bool — there is no truthiness coercion.

int

A signed integer. Produced by integer literals (5, -3), by the arithmetic operators + - * / %, by int, and by query builtins such as level, count, and hour.

string

A run of text. Produced by string literals, by interpolation, and by string-valued builtins such as name, class, and upper. A bare string is not iterable — to walk its words, convert it with words.

iterable

An iterable is an on-demand sequence — the language's universal collection. There are no arrays of game entities, only iterables over them. Builtins like creatures, inventory, and words hand you iterables; each, select, and count consume them. See Iterables and iterables.

block

A block is a first-class chunk of code, written { … }. Blocks are what you hand to each, if, select, and friends, and what a def binds to a name. See Blocks.

list

A list is an ordered, fixed-length group of values, written ( … ) or built with list. Unlike a string, a list is iterable — walking it yields its elements in order. Use a list to write a literal sequence, for instance a list of predicate blocks. A list is not itself a bool; to test whether it has elements use empty or [gt [count $l] 0].

Entity references

An entity reference points at a specific thing in the running game. Reading the reference resolves it back to the live entity, so the reference always reflects the entity's current state.

A creature or object whose entity has since been destroyed is stale. Resolving a stale reference quietly stops the script.

See also