Chapter 1: Your first script

This chapter walks you through setting a script on a mob and seeing it run. By the end you will understand the OLC workflow and have a mob that greets people when they enter the room.

Step 1: Pick a mob to edit

Choose a mob vnum in a zone you have access to. For this example we will use vnum 1200. Open it for editing:

olc medit 1200

You should see a message like "Now editing mobile 1200." If the vnum does not exist yet, OLC will create a new mob prototype.

Step 2: Open the script editor

olc mset script

This opens the built-in text editor (TEDII). You will see a ruler line and a line-number prompt. Everything you type from here is script source code.

The editor commands all start with &:

Command What it does
&h Show help
&r Refresh / redisplay
&l N text Replace line N
&d N Delete line N
&i N text Insert before line N
&e Save and exit
&q Quit without saving
@ Save and exit (shortcut)

Step 3: Write the script

Type the following script into the editor, one line per prompt:

after enter {
  do "say Welcome, [name $actor]!"
}

That is three lines. After typing the closing }, press enter, then type @ on a new line to save and compile the script.

If the script compiles successfully, you will see a message confirming the save. If there is a compile error, the error message will tell you which line has the problem — fix it with &l and save again.

Step 4: Load the mob

olc mload 1200

This loads a copy of mob 1200 into your current room. The mob now has your script attached.

Step 5: Trigger the event

Walk out of the room and back in. When you enter, you should see the mob say:

A guard says, 'Welcome, Yourname!'

Congratulations — your first script is running.

What just happened?

Let's break down the script:

after enter {
  do "say Welcome, [name $actor]!"
}

Updating a script

To change the script, repeat the process:

  1. olc medit 1200
  2. olc mset script — the editor opens with the current script.
  3. Make your changes.
  4. @ to save.

The new script takes effect immediately on all loaded copies of mob 1200 — you do not need to reload the mob.

Saving to disk

Everything so far lives in memory. To persist your changes across reboots:

olc msave

This writes the mob (and its script) to the zone's world files.

Try it yourself

Modify the script to also react when someone leaves:

after enter {
  do "say Welcome, [name $actor]!"
}

before leave {
  do "say Safe travels, [name $actor]!"
}

Walk in and out of the room. The mob should greet you on entry and wish you well when you leave.

Note the before phase on leave — the mob needs to speak while the player is still in the room. An after leave handler would run after the player has already gone.

Key points

Next: Chapter 2: Reacting to commands