Map Extension
From LSWiki
Revision as of 16:37, 10 June 2008 (edit) Matts (Talk | contribs) (Map Extension moved to Haaru Map Extension: Need to hijack this title for my coding classes.) ← Previous diff |
Current revision (15:16, 6 July 2008) (edit) Chaos (Talk | contribs) (→Daemon - room prefix optional) |
||
Line 1: | Line 1: | ||
- | #REDIRECT [[Haaru Map Extension]] | + | =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: | ||
+ | * <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. | ||
+ | * <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. | ||
+ | * <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. | ||
+ | * <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. | ||
+ | * <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. | ||
+ | |||
+ | ==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")); | ||
+ | // 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. You can leave this out entirely, in which case it will act as | ||
+ | // though you had done $1->set_room_prefix(Project_Room("map_")); | ||
+ | $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 north, south, east, west, up, and down. | ||
+ | // With this enabled you will get northeast, northwest, southeast and southwest as | ||
+ | // well. Your use of this will vary. | ||
+ | $1->set_map_directionality(Map_Directionality_Extended); | ||
+ | :)); | ||
+ | } |
Current revision
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")); // 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. You can leave this out entirely, in which case it will act as // though you had done $1->set_room_prefix(Project_Room("map_")); $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 north, south, east, west, up, and down. // With this enabled you will get northeast, northwest, southeast and southwest as // well. Your use of this will vary. $1->set_map_directionality(Map_Directionality_Extended); :)); }