Manual:Zone Manual/The Room Section/Compiling and debugging your first room

From DikuMUD Wiki
< Manual:Zone Manual‎ | The Room Section
Revision as of 06:20, 15 November 2026 by Agent-mud (talk | contribs) (checked against the current code (wiki review 2026-11-15))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Compiling and debugging your first room

Time to put the zone header and the first room together and compile them into files the server can load. The zone compiler is called vmc. This page assumes you run your own copy of the server and use vmc at the command line; if you build for a mud run by someone else, ask its administrator how to compile there. The error messages are the same either way. More about vmc and its options is in General Compiler Information.

When you start a zone, compile it after the first room or two rather than writing all the rooms first. One mistake can confuse the compiler about everything after it, and with many rooms the first mistake is hard to find.

Here is the zone header with our first room, saved as dragonst.zon. It has four mistakes in it on purpose; we fix them one at a time.

#include macros.h>

%zone dragonst
lifespan 20
reset RESET_ANYHOw
creators {"whistler"}

notes
"This is the dragon station. I shortened it to dragonst for ease in
loading."

help
"Not sure what could help you now. You are stuck on one of the
weirdest space stations you have ever seen and you smell burning
sulphur."

%rooms

chamber
title "The middle chamber of the station
descr
"This chamber seems to have the entire station rotating around it.
Small human-size ornate chairs with dragon designs on the arms and
backs are arranged in a triangle, with one large chair at the front.
This must be where all station meetings are held. Large pictures cover
the walls, showing dragons in all kinds of situations. Small passages
lead off to the west and the east."

extra {"chairs", "chair"}
"The chairs are made of some metal you don't recognise and every inch
is covered with some kind of dragon."

extra {"dragon picture", "picture"}
"Thousands of dragons dot the skies of this rather lifelike picture. In
the centre you see something move. It looks to be a little green
dragon."

extra {"green", "green dragon", "dragon"}
"An intelligent-looking dragon is sitting perched on a large chair,
watching you."

west to disposal_room descr "You see a small room.";
east to hallway descr "You see what looks to be a hallway.";
end

%end

The server reads its zones from vme/zone/, so put the file there and compile it from that directory:

cd vme/zone
../bin/vmc -d ../etc/ -I../include/ dragonst.zon

-I tells vmc where the include files such as macros.h are, and -d where the money file is. This is what we get:

VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026]
VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG]
Compiling 'dragonst.zon'
<dragonst.zon> @ 1: Bad include argument
<dragonst.zon> @ 48: EOF in string
Fatal error compiling in preprocessor stage in file 'dragonst.zon'.

(The date and the flags on the first two lines depend on your build.)

Don't let this scare you. The most important rule of compiling: fix the first error, then compile again. Once the compiler hits something it doesn't understand, it gets confused about the rest of the file, and one fix often clears several errors after it. It is like reading a book while thinking the word "water" means "fire": it gets confusing fast, and the cure is to correct "water", not every page after it.

Vmc works in two stages, and the errors come from both. The lines starting with <dragonst.zon> @ come from the preprocessor, which handles #include, #define and the like before the zone itself is read. The number after the @ is the line. Read in plain English, the first error says: in dragonst.zon, at line 1, the argument to #include is wrong. Not every error is this clear, but the compiler gets you close. Line 1 is missing the <. Fix it to read

#include <macros.h>

and compile again. Now we get a whole new set:

VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026]
VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG]
Compiling 'dragonst.zon'
<dragonst.zon> @ 48: EOF in string
v: dragonst.zon: 5: syntax error
   Token: 'RESET_ANYHOw'
v: dragonst.zon: 22: syntax error
   Token: 'This'
v: dragonst.zon: 27: syntax error
   Token: 'and'
v: dragonst.zon: 27: syntax error
   Token: '.'
Grave errors in file 'dragonst.zon'.

The lines starting with v: are syntax errors from the second stage: the file name, the line number, and the word (token) the compiler choked on. Which one to fix first takes a little thought. "EOF in string" at line 48 comes first, but the file has only 47 lines: somewhere a string was opened and never closed, and the compiler only noticed at the end of the file. The lowest line number is the better place to start, so we look at line 5. The compiler doesn't know RESET_ANYHOw. Of course: it should be RESET_ANYHOW, and the compiler is case-sensitive. Fix the w and compile again:

VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026]
VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG]
Compiling 'dragonst.zon'
<dragonst.zon> @ 48: EOF in string
v: dragonst.zon: 22: syntax error
   Token: 'This'
v: dragonst.zon: 27: syntax error
   Token: 'and'
v: dragonst.zon: 27: syntax error
   Token: '.'
Grave errors in file 'dragonst.zon'.

The lowest line is now 22. Line 22 is the first line of the description, and it looks fine. When an error makes no sense on its own line, look at the field before it. The title on line 20 has no closing ", so the title string ran on to the quote that should have opened the description. The compiler then read This as a field name, which it isn't. This is one of the harder errors to find, but it gets easier with practice. Add the missing " and compile again:

VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026]
VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG]
Compiling 'dragonst.zon'
FATAL: Name order error (or matching names) for 'green dragon' in chamber@
WARNING: Fatal errors in zone.

One quote cleared three syntax errors and the "EOF in string". That is why you fix one error at a time: a single quote can cause dozens of errors that make no sense, and if you jump around fixing the ones that seem to, you make more work for yourself.

The syntax is now right, and this error comes from the checks vmc runs on each unit afterwards. These messages are also written to dragonst.err. The extra {"green", "green dragon", "dragon"} breaks the rule for name lists: no name may start with an earlier one, and "green dragon" starts with "green". Put the longest name first, {"green dragon", "dragon", "green"}, and compile once more:

VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026]
VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG]
Compiling 'dragonst.zon'
VMC Done.

No errors, and VMC Done.: the zone is compiled. You should now have these files next to dragonst.zon:

dragonst.data
dragonst.dot
dragonst.err
dragonst.reset
dragonst.zon

dragonst.data and dragonst.reset are what the server loads. dragonst.err holds the warnings and errors from the unit checks (empty now), and dragonst.dot is a map of the zone's rooms and exits for the Graphviz program. A zone with DIL also gets a .dh file.

A few things vmc does not check, so a clean compile isn't the end:

  • where exits lead: our two exits point at rooms we haven't written yet;
  • the names and arguments of DIL templates in dilcopy;
  • key and reset references to objects and NPCs.

Mistakes there show up when the server boots. It writes them to vme/bin/vme.log and adds them to the zone's .err file.

To get the zone into the game:

  1. Add a line for dragonst to vme/etc/zonelist; copy one of the lines there and change the name. A blank line ends that file: zones listed after it are never loaded.
  2. Restart the server (vme). It reads zones only at boot.
  3. Look for dragonst in vme/bin/vme.log. Our two exits are reported as "Unknown room direction" until we write those rooms.
  4. Log in with a god character and type goto chamber@dragonst. In the game, wstat zone dragonst errors shows the zone's .err file, with the boot errors.

While you work on a zone, -m compiles only the zones that changed since their last compile (../bin/vmc -m -d ../etc/ -I../include/ *.zon), and -l turns warnings into errors.

You have now compiled your first zone. It is not much to look at yet, but with what you know you could build a whole zone of simple rooms. The next sections show the more interesting things rooms can do.

Previous: Building your first room
Next: DIL functions for rooms