Difference between revisions of "Manual:Zone Manual/General Compiler Information"

From DikuMUD Wiki
Jump to navigation Jump to search
(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.
  
−
In order to get your zone onto a valhalla Mud Engine (VME) server you must convert your zone from readable
+
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.
−
english text to binary form the server can understand.  The way
 
−
you do this is with a compiler.  No don't freak out you don't have
 
−
to be a skilled programmer to use a compiler.  The only thing you
 
−
have to do is format your rooms, objects, and Non-player characters
 
−
(NPC) in a form which the compiler can understand.  The great thing
 
−
about the VME is you can do all your zone writing in your favorite
 
−
editor with out having to log on to code.  For those of you who have
 
−
coded for other mud servers and are used to coding online this may
 
−
be a new experience to you but you will find you can plan out
 
−
better and more well designed areas offline than you can on
 
−
line.
 
  
−
<blockquote style="background-color: #E8E8E8; font-style: italic; ">
+
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.
−
In the future the VME coding team is thinking of adding
 
−
an online coding module for those mud administrators that can not
 
−
live with out it. If you are one of these make sure you write
 
−
whistler@valhalla.com and express your desires so
 
−
you can be counted.
 
−
</blockquote>
 
  
−
This chapter will mainly cover the Valhalla Mud Compiler (VMC), how it works, and
 
−
the Valhalla Mud pre processor (VMC -p) works.  We will also throw in some debugging
 
−
hints but debugging will be covered more as you begin creating parts of
 
−
your areas in the following chapters.
 
 
=== 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".
  
−
''VMC'' is the Valhalla Mud Engine Compiler.
+
The zones live in <code>vme/zone/</code>, and vmc is built into <code>vme/bin/</code>. Compile from the zone directory:
−
for VME servers. A compiler takes a source file or better described
+
<pre>
−
as your areas input file and converts it to a binary file the
+
cd vme/zone
−
server can then load and use online. In the VME we call areas
+
../bin/vmc -d ../etc/ -I../include/ dragon.zon
−
you build 'zones', therefore the source file for a zone has the
+
</pre>
−
extension 'zon'. In order to make this more clear we will start
+
<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:
−
with our first example.
+
<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:
  
−
Lets say you were making a Zone of dragons. You may want to
+
{| class="wikitable"
−
call the file something resembling its contents like,
+
! File !! What it is
−
''dragon.zon''. Notice we have appended the
+
|-
−
'.zon' extension.  The compiler requires all zones to end in '.zon'
+
| <code>dragon.data</code> || The rooms, objects, NPCs and DIL programs, in binary. The server loads it.
−
in order for it to know this is a zone source file.
+
|-
 +
| <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.
 +
|}
  
−
Now lets say we have completed writing our first zone and want
+
<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.
−
to compile it.  The command is simply:
 
−
'''VMC> dragon.zon'''
 
−
If the zone compiles correctly it will indicate success by printing
 
−
a message to the screen and outputting two files both with the same
 
−
root name as the original zone source file but with different
 
−
extensions. In this case there would be the following:
 
  
−
;''dragon.data''
+
=== Options ===
−
: The file holding the binary version of the zone
+
{| class="wikitable"
−
;''dragon.reset''
+
! Option !! What it does
−
: The file containing the reset information for the zone.
+
|-
 +
| <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.
 +
|}
  
−
If the zone doesn't compile correctly and you have errors it will print a list of the errors and the location where they can be found so you can fix them. The debugging process will be explained more as you learn how to create rooms, monsters, and objects.
+
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

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

  1. Compile the zone.
  2. 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.
  3. Restart the server. It reads zones only when it boots.
  4. Read vme/bin/vme.log for messages about your zone, and walk through it in the game.
Previous: Introduction
Next: The VMC pre-processor