Difference between revisions of "Manual:Zone Manual/General Compiler Information"
(checked against the current code (wiki review 2026-11-15)) |
|||
| Line 1: | Line 1: | ||
== General compiler information == | == General compiler information == | ||
| + | A zone is written as plain text, but the server doesn't read that text. '''vmc''', the zone compiler, turns it into binary files, and the server loads those when it boots. You don't need to be a programmer to use vmc: you write your rooms, objects and NPCs in the form this manual describes, and vmc tells you where it can't understand you. | ||
| − | + | Because zones are written offline, in your own editor, you can plan an area as a whole and keep it under version control like any other source file. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | This chapter covers running vmc and reading its messages. The next page covers the [[Manual:Zone_Manual/General_Compiler_Information/The_VMC_pre-processor|pre-processor]], which handles comments, macros and include files before vmc reads the zone. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
=== The compiler === | === The compiler === | ||
| + | A zone's source file has the extension <code>.zon</code>, and its name is the zone's name. A zone of dragons could be <code>dragon.zon</code>, starting with <code>%zone dragon</code>. The two must match: vmc accepts a different name in <code>%zone</code>, but the server stops at boot with "Zone name ... must match the filename on disk". | ||
| − | + | The zones live in <code>vme/zone/</code>, and vmc is built into <code>vme/bin/</code>. Compile from the zone directory: | |
| − | + | <pre> | |
| − | + | cd vme/zone | |
| − | + | ../bin/vmc -d ../etc/ -I../include/ dragon.zon | |
| − | + | </pre> | |
| − | + | <code>-d ../etc/</code> tells vmc where the money definitions are, and <code>-I../include/</code> where the macro headers are. A zone that compiles prints: | |
| − | + | <pre> | |
| + | VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] | ||
| + | VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] | ||
| + | Compiling 'dragon.zon' | ||
| + | VMC Done. | ||
| + | </pre> | ||
| + | (The first two lines show when and how your vmc was built.) vmc writes these files next to the source: | ||
| − | + | {| class="wikitable" | |
| − | + | ! File !! What it is | |
| − | + | |- | |
| − | + | | <code>dragon.data</code> || The rooms, objects, NPCs and DIL programs, in binary. The server loads it. | |
| − | + | |- | |
| + | | <code>dragon.reset</code> || The reset interval, reset mode and the <code>%reset</code> commands. The server loads it. | ||
| + | |- | ||
| + | | <code>dragon.err</code> || The errors and warnings found after reading the file (empty when there are none). | ||
| + | |- | ||
| + | | <code>dragon.dh</code> || Only for zones with DIL: the zone's DIL templates, ready to copy into an <code>external</code> list. | ||
| + | |- | ||
| + | | <code>dragon.dot</code> || A map of the rooms and exits for Graphviz. | ||
| + | |} | ||
| − | + | <code>make all</code> from the top of the repository also compiles every zone in <code>vme/zone/</code> (the <code>zone_files</code> target), and recompiles a zone when a header in <code>vme/include/</code> changes. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | === Options === | |
| − | : The | + | {| class="wikitable" |
| − | + | ! Option !! What it does | |
| − | : The | + | |- |
| + | | <code>-m</code> || Compile only zones whose <code>.zon</code> is newer than their <code>.data</code> and <code>.reset</code>. It looks only at the <code>.zon</code> file itself: after changing a header or an included file, leave out <code>-m</code>. | ||
| + | |- | ||
| + | | <code>-s</code> || Check only: write no <code>.data</code> or <code>.reset</code>. The <code>.err</code> (and <code>.dh</code>) are still written. | ||
| + | |- | ||
| + | | <code>-l</code> || Treat warnings as errors. | ||
| + | |- | ||
| + | | <code>-q</code> || Quiet: leave out the banner and most warnings; errors are still printed. | ||
| + | |- | ||
| + | | <code>-v</code> || Verbose: also print a table of each NPC's abilities, and the values and bonuses of weapons, armour and other items. | ||
| + | |- | ||
| + | | <code>-p</code> || Only run the pre-processor and print the result. Use it to see what a macro became. | ||
| + | |- | ||
| + | | <code>-d</code> ''dir/'' || The directory with the money file (<code>money</code>). Write it with the trailing <code>/</code>: vmc appends <code>money</code> to it. The default is <code>../etc/</code>, or the value of the environment variable <code>VME_MONEY</code>. | ||
| + | |- | ||
| + | | <code>-I</code>''dir/'' || Search ''dir'' for include files. Write it without a space: <code>-I../include/</code>. You can give several. | ||
| + | |- | ||
| + | | <code>-j</code> || Also write the zone as JSON (<code>.json</code>). It crashes in the current version; don't use it. | ||
| + | |- | ||
| + | | <code>-h</code> || Show the list of options. | ||
| + | |} | ||
| − | + | Give each option on its own (<code>-m -s</code>, not <code>-ms</code>: vmc reads only the first letter), and put the options before the zone files. You can compile several zones at once: | |
| + | <pre> | ||
| + | ../bin/vmc -m -d ../etc/ -I../include/ *.zon | ||
| + | </pre> | ||
| + | vmc stops at the first zone that has errors; the zones after it are not compiled. | ||
| + | |||
| + | === Errors and warnings === | ||
| + | A syntax error stops the compile at once. vmc prints the file, the line and the word (token) where it gave up. This <code>dragon.zon</code> has a typing error on line 12: | ||
| + | <pre> | ||
| + | #include <macros.h> | ||
| + | |||
| + | %zone dragon | ||
| + | title "Dragon Station" | ||
| + | lifespan 20 | ||
| + | reset RESET_ANYHOW | ||
| + | creators {"whistler"} | ||
| + | |||
| + | %rooms | ||
| + | |||
| + | altar | ||
| + | titel "The dark dragon altar" | ||
| + | descr | ||
| + | "A black stone altar fills the middle of the room." | ||
| + | end | ||
| + | |||
| + | %end | ||
| + | </pre> | ||
| + | <pre> | ||
| + | VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] | ||
| + | VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] | ||
| + | Compiling 'dragon.zon' | ||
| + | v: dragon.zon: 12: syntax error | ||
| + | Token: 'titel' | ||
| + | Compilation aborted. | ||
| + | </pre> | ||
| + | The mistake is on that line or just before it. A string that isn't closed with <code>"</code> swallows the rest of the file, and the error then shows up far below it. | ||
| + | |||
| + | When the whole file has been read, vmc checks the values: names, titles, weights, NPC abilities and more. These messages start with <code>FATAL</code> or <code>WARNING</code>, and they also go to the <code>.err</code> file. With this object in the zone: | ||
| + | <pre> | ||
| + | %objects | ||
| + | |||
| + | small_item | ||
| + | names {"small", "item", "small item"} | ||
| + | title "A small item." | ||
| + | descr "A small item lies here." | ||
| + | end | ||
| + | </pre> | ||
| + | vmc prints: | ||
| + | <pre> | ||
| + | VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] | ||
| + | VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] | ||
| + | Compiling 'dragon.zon' | ||
| + | FATAL: Name order error (or matching names) for 'small item' in small_item@ | ||
| + | WARNING: small_item: Title CASE seems to be wrong for 'A small item.' | ||
| + | WARNING: small_item: Title ends with non-alphabet character 'A small item.' | ||
| + | WARNING: Fatal errors in zone. | ||
| + | </pre> | ||
| + | A fatal error means no zone is written. Warnings alone still give you a zone; with <code>-l</code> they count as errors. ([[Manual:Zone_Manual/Unit_Building_Blocks|Unit Building Blocks]] explains these three.) | ||
| + | |||
| + | An error in a DIL program gives the line of the error, then the line where vmc gave up on that program. This zone has a DIL program with a mistake on line 9: | ||
| + | <pre> | ||
| + | #include <macros.h> | ||
| + | |||
| + | %zone dragon | ||
| + | |||
| + | %dil | ||
| + | |||
| + | dilbegin hello(); | ||
| + | var | ||
| + | name : string; | ||
| + | code | ||
| + | { | ||
| + | quit; | ||
| + | } | ||
| + | dilend | ||
| + | |||
| + | %end | ||
| + | </pre> | ||
| + | <pre> | ||
| + | VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] | ||
| + | VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] | ||
| + | Compiling 'dragon.zon' | ||
| + | DIL (line 7)D: | ||
| + | 9: syntax error | ||
| + | Token: 'name' | ||
| + | dragon.zon: 14: DIL not compiled properly. | ||
| + | </pre> | ||
| + | Line 9 declares a variable called <code>name</code>, but <code>name</code> is a reserved word in DIL. For a zone with DIL that compiles, vmc prints a line for each program, with its name and size. | ||
| + | |||
| + | If vmc fails, the old <code>.data</code> and <code>.reset</code> stay where they are, and the server will load those. Check that the compile succeeded before you test. | ||
| + | |||
| + | The later chapters show the common errors for rooms, objects and NPCs. | ||
| + | |||
| + | === What vmc doesn't check === | ||
| + | A clean compile doesn't mean the zone works. vmc doesn't check references: an exit to a room that doesn't exist, a key, a <code>dilcopy</code> of a template that doesn't exist, or a reset that loads a unit that isn't there all compile without a word. The server finds them when it boots and writes them to its log (<code>vme/bin/vme.log</code>). | ||
| + | |||
| + | === Getting the zone into the game === | ||
| + | # Compile the zone. | ||
| + | # If it is a new zone, add a line for it to <code>vme/etc/zonelist</code>. Copy the line of a similar zone and change the first word to your zone's name. The server reads that file only up to the first blank line, so add your line above any blank line. | ||
| + | # Restart the server. It reads zones only when it boots. | ||
| + | # Read <code>vme/bin/vme.log</code> for messages about your zone, and walk through it in the game. | ||
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/Introduction|Previous: Introduction]]</div> | <div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/Introduction|Previous: Introduction]]</div> | ||
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/General_Compiler_Information/The_VMC_pre-processor|Next: The VMC pre-processor]]</div> | <div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/General_Compiler_Information/The_VMC_pre-processor|Next: The VMC pre-processor]]</div> | ||
Latest revision as of 06:19, 15 November 2026
Contents
General compiler information
A zone is written as plain text, but the server doesn't read that text. vmc, the zone compiler, turns it into binary files, and the server loads those when it boots. You don't need to be a programmer to use vmc: you write your rooms, objects and NPCs in the form this manual describes, and vmc tells you where it can't understand you.
Because zones are written offline, in your own editor, you can plan an area as a whole and keep it under version control like any other source file.
This chapter covers running vmc and reading its messages. The next page covers the pre-processor, which handles comments, macros and include files before vmc reads the zone.
The compiler
A zone's source file has the extension .zon, and its name is the zone's name. A zone of dragons could be dragon.zon, starting with %zone dragon. The two must match: vmc accepts a different name in %zone, but the server stops at boot with "Zone name ... must match the filename on disk".
The zones live in vme/zone/, and vmc is built into vme/bin/. Compile from the zone directory:
cd vme/zone ../bin/vmc -d ../etc/ -I../include/ dragon.zon
-d ../etc/ tells vmc where the money definitions are, and -I../include/ where the macro headers are. A zone that compiles prints:
VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] Compiling 'dragon.zon' VMC Done.
(The first two lines show when and how your vmc was built.) vmc writes these files next to the source:
| File | What it is |
|---|---|
dragon.data |
The rooms, objects, NPCs and DIL programs, in binary. The server loads it. |
dragon.reset |
The reset interval, reset mode and the %reset commands. The server loads it.
|
dragon.err |
The errors and warnings found after reading the file (empty when there are none). |
dragon.dh |
Only for zones with DIL: the zone's DIL templates, ready to copy into an external list.
|
dragon.dot |
A map of the rooms and exits for Graphviz. |
make all from the top of the repository also compiles every zone in vme/zone/ (the zone_files target), and recompiles a zone when a header in vme/include/ changes.
Options
| Option | What it does |
|---|---|
-m |
Compile only zones whose .zon is newer than their .data and .reset. It looks only at the .zon file itself: after changing a header or an included file, leave out -m.
|
-s |
Check only: write no .data or .reset. The .err (and .dh) are still written.
|
-l |
Treat warnings as errors. |
-q |
Quiet: leave out the banner and most warnings; errors are still printed. |
-v |
Verbose: also print a table of each NPC's abilities, and the values and bonuses of weapons, armour and other items. |
-p |
Only run the pre-processor and print the result. Use it to see what a macro became. |
-d dir/ |
The directory with the money file (money). Write it with the trailing /: vmc appends money to it. The default is ../etc/, or the value of the environment variable VME_MONEY.
|
-Idir/ |
Search dir for include files. Write it without a space: -I../include/. You can give several.
|
-j |
Also write the zone as JSON (.json). It crashes in the current version; don't use it.
|
-h |
Show the list of options. |
Give each option on its own (-m -s, not -ms: vmc reads only the first letter), and put the options before the zone files. You can compile several zones at once:
../bin/vmc -m -d ../etc/ -I../include/ *.zon
vmc stops at the first zone that has errors; the zones after it are not compiled.
Errors and warnings
A syntax error stops the compile at once. vmc prints the file, the line and the word (token) where it gave up. This dragon.zon has a typing error on line 12:
#include <macros.h>
%zone dragon
title "Dragon Station"
lifespan 20
reset RESET_ANYHOW
creators {"whistler"}
%rooms
altar
titel "The dark dragon altar"
descr
"A black stone altar fills the middle of the room."
end
%end
VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] Compiling 'dragon.zon' v: dragon.zon: 12: syntax error Token: 'titel' Compilation aborted.
The mistake is on that line or just before it. A string that isn't closed with " swallows the rest of the file, and the error then shows up far below it.
When the whole file has been read, vmc checks the values: names, titles, weights, NPC abilities and more. These messages start with FATAL or WARNING, and they also go to the .err file. With this object in the zone:
%objects
small_item
names {"small", "item", "small item"}
title "A small item."
descr "A small item lies here."
end
vmc prints:
VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] Compiling 'dragon.zon' FATAL: Name order error (or matching names) for 'small item' in small_item@ WARNING: small_item: Title CASE seems to be wrong for 'A small item.' WARNING: small_item: Title ends with non-alphabet character 'A small item.' WARNING: Fatal errors in zone.
A fatal error means no zone is written. Warnings alone still give you a zone; with -l they count as errors. (Unit Building Blocks explains these three.)
An error in a DIL program gives the line of the error, then the line where vmc gave up on that program. This zone has a DIL program with a mistake on line 9:
#include <macros.h>
%zone dragon
%dil
dilbegin hello();
var
name : string;
code
{
quit;
}
dilend
%end
VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026]
VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG]
Compiling 'dragon.zon'
DIL (line 7)D:
9: syntax error
Token: 'name'
dragon.zon: 14: DIL not compiled properly.
Line 9 declares a variable called name, but name is a reserved word in DIL. For a zone with DIL that compiles, vmc prints a line for each program, with its name and size.
If vmc fails, the old .data and .reset stay where they are, and the server will load those. Check that the compile succeeded before you test.
The later chapters show the common errors for rooms, objects and NPCs.
What vmc doesn't check
A clean compile doesn't mean the zone works. vmc doesn't check references: an exit to a room that doesn't exist, a key, a dilcopy of a template that doesn't exist, or a reset that loads a unit that isn't there all compile without a word. The server finds them when it boots and writes them to its log (vme/bin/vme.log).
Getting the zone into the game
- Compile the zone.
- If it is a new zone, add a line for it to
vme/etc/zonelist. Copy the line of a similar zone and change the first word to your zone's name. The server reads that file only up to the first blank line, so add your line above any blank line. - Restart the server. It reads zones only when it boots.
- Read
vme/bin/vme.logfor messages about your zone, and walk through it in the game.