XData File Creation

From The DarkMod Wiki
Revision as of 13:18, 23 September 2007 by Fidcal (talk | contribs) (clarification)
Jump to navigationJump to search

In order to get custom text for readables into your map, you will have to define the texts somewhere. This happens in the files within the xdata/ folder.

I will describe a basic single-page readable here. Hopefully I will be able to add more information on creating books and other multi-page readables. See also xdata file format for detailed information.

Create the .xd File

Create a new .xd file named after your map file. If your map file is called "readable_tutorial.map", create the file xdata/readable_tutorial.xd. (note: the xd file can be any name but it makes sense to use map name when published for identification and to avoid conflict etc. For example darkmanor.xd will work fine with darkmanor448.map and darkmanor449.map etc. or even just 449.map during development.)

To save time-consuming syntax typing, I suggest copying the content of another .xd file right into yours. There is are already the file readable_test.xd in the xdata/ folder. Open it and copy all of its content into yours.

A basic readable text can be defined by these two blocks (it's the same text that is used in the Readables Tutorial):

The Main Block

readables/readable_tutorial/sample
{
   precache
   "gui_page1"   : "guis/readables/page_test.gui"
   import {
       "title" -> "page1_title"
       "body"  -> "page1_body"
   } from "readables/readable_tutorial/page1"
}

This block is some kind of "Table of Contents" of your readable. It defines which gui templates each page of your readable is using and which texts are to be displayed. The important part is the first line

readables/readable_tutorial/sample

which is the name used to access this text in the editor. This value corresponds to the xdata_contents key of your readable entity.

Secondly, there is the import { ... } from command, which tells the readable where to look for the actual text to be display on Page 1. It refers to the data block defined below.

The Data Block

readables/readable_tutorial/page1
{
   "title" : "W00t!"
   "body"  : "This is a damn fine readable. Read it at your own risk." \
             "Absolutely frobable. Totally customizable. Choose your own " \
             "background, your own font, your own text size! Heck, even " \
             "custom texts are possible..."
}

Again, the name of the block is important, as it is referred to in the master block. The syntax is quite straight forward, just be sure to add a backslash at the end of the strings to connect them. The last string does not have a backslash.

Custom Fonts and Stuff

You can use custom fonts, font sizes and backgrounds in your readables. These are defined in the .gui file which is referred to in the master block:

"gui_page1"   : "guis/readables/page_test.gui"

Each page can use its own gui (for example if you plan to display page 1 as the book's cover and the rest as ordinary book pages). The tutorial is still to be written: GUI Definitions