Tempus Script Guide

A cookbook for the Tempus scripting language. Where the tutorial teaches the language one concept at a time and the reference answers "what does this one built-in do?", this guide is organized around what you want the script to accomplish. Each chapter is a set of recipes for a kind of behavior — making an NPC talk, searching a room, remembering a visitor, spawning an item, surviving combat — with the built-ins and language features woven in where the behavior needs them.

If you are brand new, start with the tutorial. If you want the exact rules, the language specification is authoritative on correctness. Read this guide when you know what you want to do and want the idiomatic how.

How to read a recipe

Most examples are handler fragments — a before/handle/after block bound to an event — that you can paste into a mob, object, or room script with OLC. Read a bare statement as if it sat inside an enclosing handler body. A line beginning with # is a comment and does nothing.

# greet the first player to speak nearby
after command (say) {
  require [isplayer $actor]
  echo $actor "The old man nods at you."
}

Every built-in and language construct appears in at least one worked example somewhere in these chapters; the final Coverage index maps each one to where it is shown.

Chapters

  1. Reacting to events — choosing the right event and phase, filters, bound variables, require/unless guards, and intercepting the default action.
  2. Talking, emoting, and messagingdo, echo, emit, force, silently, pronouns, string interpolation, and varying responses with randomly.
  3. Finding things in the world — producing and consuming iterables: looping, filtering, counting, picking, and testing membership.
  4. Inspecting entities — reading an entity's attributes, telling players from mobs, locating objects, and guarding against null or stale references.
  5. Numbers, text, and logic — arithmetic, comparison, the logic operators, random rolls, conversions, and if as an expression.
  6. Variables, scope, and memorylet, set, const, lexical scope, the counter idiom, persistent store/recall/forget, and player tags.
  7. Changing the world — spawning and purging, teleporting, doors and exits, prototypes, behavior flags, and making a mob travel.
  8. Combat, damage, and death — reacting to combat, dealing and healing damage, casting, rewarding kills, and intercepting death.
  9. Structuring larger scriptsdef, top-level const, blocks as values, & references, rest parameters, the /> threading operator, control flow, pause, and nuke.
  10. Coverage index — every built-in and feature, mapped to the chapter that demonstrates it.

A note on owners

A script's owner ($self) is the mob, object, or room it is attached to. Some recipes only make sense for a particular owner: do, silently, walkto, selfpurge, and mobflag need a mobile owner; ldesc works on a mob or object; object handlers like get/wear live on the object being acted on. Each recipe notes when the owner matters.