Map Extension

From LSWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 17:34, 10 June 2008 (edit)
Matts (Talk | contribs)

← Previous diff
Revision as of 17:42, 10 June 2008 (edit)
Chaos (Talk | contribs)
(What parts are there to the map extension?)
Next diff →
Line 4: Line 4:
==What parts are there to the map extension?== ==What parts are there to the map extension?==
There are numerous things that the map extension will require to function properly, other than simply attaching the extension itself to your project's control daemon. The specifics of which I will detail below, but the following items are needed to create a basic and functioning map. Keep in mind that the file names I give below are simply the 'defacto standard' that we all tend to use. These names can vary, though for consistency sake it's recommended that they do not: There are numerous things that the map extension will require to function properly, other than simply attaching the extension itself to your project's control daemon. The specifics of which I will detail below, but the following items are needed to create a basic and functioning map. Keep in mind that the file names I give below are simply the 'defacto standard' that we all tend to use. These names can vary, though for consistency sake it's recommended that they do not:
-* /dat/map.conf+* <i>Project</i>/dat/map.conf
** This file is where you create the ASCII-character grid representing your map, define the dimensions of your map, and define where your overlays are placed. ** This file is where you create the ASCII-character grid representing your map, define the dimensions of your map, and define where your overlays are placed.
-* /def/map_area_*+* <i>Project</i>/def/map_area_*
** The map_area definitions are used to specify the bulk of your area's content. Each definition you create will define a specific element for your map, such as 'grass', and what any room defined as 'grass' should look like and/or contain. ** The map_area definitions are used to specify the bulk of your area's content. Each definition you create will define a specific element for your map, such as 'grass', and what any room defined as 'grass' should look like and/or contain.
-* /def/map_overlay_*+* <i>Project</i>/def/map_overlay_*
** Like map_area above map_overlay lets you define the same things, but lets you define them in the style of an overlay. What this allows you to do is to create overlapping parts on your map, such as trails, small creeks, roads, signs, or whatever you may think of. ** Like map_area above map_overlay lets you define the same things, but lets you define them in the style of an overlay. What this allows you to do is to create overlapping parts on your map, such as trails, small creeks, roads, signs, or whatever you may think of.
-* /dmn/control.c+* <i>Project</i>/dmn/control.c
** The control daemon is where you will actually attach the map extension and initialize it with the information it needs to find these other vital parts. The control daemon will also act as a broker daemon to collect and grant access to your definitions above. ** The control daemon is where you will actually attach the map extension and initialize it with the information it needs to find these other vital parts. The control daemon will also act as a broker daemon to collect and grant access to your definitions above.
-* /rms/Map_Base.c+* <i>Project</i>/rms/Map_Base.c
** This file will be used by the map extension to generate every room it creates, so many things that are common or shared among every room in your project may be defined here. ** This file will be used by the map extension to generate every room it creates, so many things that are common or shared among every room in your project may be defined here.
 +
==Why should I use the map extension for creating my area?== ==Why should I use the map extension for creating my area?==
Versitility, consistency, maintainability, flexibility, ease of use in creating massive areas on-the-fly, etc. Versitility, consistency, maintainability, flexibility, ease of use in creating massive areas on-the-fly, etc.

Revision as of 17:42, 10 June 2008

Contents

Introduction

What is the map extension?

The map extension taken in the context of itself is an extension that, like any other, modifies another object to provide additional functionality beyond its normal scope. In the case of the map extension this allows a daemon (typically a control/broker daemon) to dynamically create, maintain, and facilitate the creation of an area. Where, before, this would have been done entirely by hand - coding sometimes dozens of similiar rooms and linking them all manually - the map extension allows the content developer to quickly and consistently define what their area should look like and leaves the creation of the bulk of these rooms up to the daemon.

What parts are there to the map extension?

There are numerous things that the map extension will require to function properly, other than simply attaching the extension itself to your project's control daemon. The specifics of which I will detail below, but the following items are needed to create a basic and functioning map. Keep in mind that the file names I give below are simply the 'defacto standard' that we all tend to use. These names can vary, though for consistency sake it's recommended that they do not:

  • Project/dat/map.conf
    • This file is where you create the ASCII-character grid representing your map, define the dimensions of your map, and define where your overlays are placed.
  • Project/def/map_area_*
    • The map_area definitions are used to specify the bulk of your area's content. Each definition you create will define a specific element for your map, such as 'grass', and what any room defined as 'grass' should look like and/or contain.
  • Project/def/map_overlay_*
    • Like map_area above map_overlay lets you define the same things, but lets you define them in the style of an overlay. What this allows you to do is to create overlapping parts on your map, such as trails, small creeks, roads, signs, or whatever you may think of.
  • Project/dmn/control.c
    • The control daemon is where you will actually attach the map extension and initialize it with the information it needs to find these other vital parts. The control daemon will also act as a broker daemon to collect and grant access to your definitions above.
  • Project/rms/Map_Base.c
    • This file will be used by the map extension to generate every room it creates, so many things that are common or shared among every room in your project may be defined here.

Why should I use the map extension for creating my area?

Versitility, consistency, maintainability, flexibility, ease of use in creating massive areas on-the-fly, etc.

When should I not use the map extension for creating my area?

Never.

Setup

Daemon

First, we'll setup a basic control daemon for your project, and go ahead and attach the map extension to it with basic parameters defined. If you complete this step and attempt to reload it and it breaks horribly, don't worry. It's going to until we get everything else together!

#include <Project.h>
#include <daemon.h>
inherit "/std/daemon";
// It's important to inherit these two mods!  Broker allows us to register definition files with this daemon, very important.
inherit "/mod/daemon/control";
inherit "/mod/daemon/broker";
void configure() {
    ::configure();
    set_creator("developer");
    set_area("Project Name");
    // This tells our broker daemon what files to look for and attempt to register with itself.  In this case we want to load and register all of our map_* definitions so that the extension can use them.  It will expect to find them here.
    set_definition_registration(([
        Project_Definition("map_*") : 0,
    ]));
    // Same as the above, but used for unloading the definitions.
    set_definition_unregistration(([
        Project_Definition("map_*") : 0,
    ]));
    // Here we actually attach the map extension to this daemon, and give it some initial parameters.  These are the most common ones you will find used.
    add_extension(LS_Extension("map"), (:
        // As noted above, the base room that the map extension will use to spawn every room it creates.
        $1->set_base_room(Project_Room("Map_Base.c"));
        // This tells the extension what prefix you want your generated rooms to begin with.  This can be anything, but short and sweet is preferred.  m_ as shown here is a solid choice.
        $1->set_room_prefix(Project_Room("m_"));
        // This tells the extension where to find the file that its configuration should be based from.  Standard use is map.conf as noted above.
        $1->set_map_conf(Project_Data("map.conf"));
        // This tells the extension to extend the directions it will offer exits to other rooms in.  Without it you will only get the cardinal directions, north, east, south and west.  With this enabled you will get northeast, northwest and the others as well.  Your use of this will vary.
        $1->set_map_directionality(Map_Directionality_Extended);         
    :));
}
Personal tools