EDF: Difference between revisions

From Eternity Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(32 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''EDF''', which stands for Eternity Definition Files, is a new data specification language that allows dynamic definition of sprites, thing types, frames, and other previously internal data.
'''EDF''', Eternity Definition File, is a language used to define and modify monsters, decorations, sounds, text strings, menus, terrain types, and other data in Eternity Engine.


EDF supercedes DeHackEd, and should become the preferred method for "exe" editing in the future. However, EDF retains features that allow DeHackEd compatibility, and DeHackEd patches may be loaded over EDF, and even have access to "new" things and frames that are defined by it.
*[[EDF basics]]


Each section of this page deals with one of the EDF constructs, as well as showing their locations in the default EDF files. However, user-made EDF files can, with a few caveats, contain these structures in any arrangement of files and in any order. User EDF files do not need to use the same names or arrangements as the defaults, and they should NEVER be intended to overwrite the Eternity Engine's default files, unless they are being provided with a customized distribution of the engine itself.
{{Backto|Eternity Engine}}


Plans are in place to steadily introduce more features and functionality to EDF in future versions of the Eternity Engine, including most notably, weapon definitions. This documentation will be regularly updated to reflect all changes and additions.
==Tutorials==
* [[Creating a simple decoration]]
* [[Creating a monster]]
* [[Creating a projectile]]
* [[Creating a pickup]]
* [[Creating terrain types]]
* [[Using inheritance]]
* [[Using deltas to modify existing definitions]]


==Syntax==
==Editing Reference==
===EDF is Free-form===
{{EDF_REF}}
 
[[category:EDF]]
Whitespace and token positioning are totally free-form in EDF. In addition, semicolons are discarded as whitespace and can therefore be used to terminate field assignments, lists, etc. as in C or C++. As an example, all of the following are strictly equivalent:
 
    thingtype w00t { mass = 1000 }
 
    thingtype w00t
    {
        mass = 1000;
    }
 
    thingtype
                      w00t
                {
        mass    =
            1000    ;;;;;;
                    }
 
The usage of a clean and consistent format is encouraged, even though it is not required.
 
===Comments===
 
EDF files can use three forms of comments:
 
* # Comments: Like in DeHackEd, this comment type extends to the end of the line.
* // Comments: An alternate form of single-line comment, equivalent to #.
* /* */ Comments: This type of comment is multiline, and extends from the opening /* to the first */ found. This type of comment CANNOT be nested. Nested multiline comments will cause a syntax error.
 
Examples:
 
    # Single line comment
 
    // Another single line comment
 
    /*
   
        This is a multiline comment
       
    */
 
===Strings===
 
Many fields in EDF take strings. Strings, if they do not contain whitespace or any character that needs to be escaped, may be unquoted. Unquoted strings additionally cannot contain any of the following characters: " ' = { } ( ) + , # / ;
If any of those characters are found, the unquoted string will be terminated at the last valid character.
 
Example:
 
    spritenames += { SPR1, SPR2, SPR3 }
 
The items SPR1, SPR2, and SPR3 are unquoted strings. Note how the commas serve to separate the items in a list, and therefore do not become part of the strings.
 
Many fields more or less require quoted strings. Quoted strings must start and end with either single or double quotes (the beginning and ending quote types must match). Quoted strings may contain any character except a line break, including those not allowed in unquoted strings. In addition, quoted strings also support the following escape codes for non-typable characters:
 
* \n : Hard line break
* \t : Tab
* \b : Backspace
* \a : Beep (causes a sound when printed to the console)
* \\ : Literal \ character.
* \" : Literal ", necessary to use in double-quoted strings only
* \' : Literal ', necessary to use in single-quoted strings only
* \0 : Null character
* \K : Changes text color to "brick" range where supported.
* \1 : Changes text color to "tan" range where supported.
* \2 : Changes text color to "gray" range where supported.
* \3 : Changes text color to "green" range where supported.
* \4 : Changes text color to "brown" range where supported.
* \5 : Changes text color to "gold" range where supported.
* \6 : Changes text color to "red" range where supported.
* \7 : Changes text color to "blue" range where supported.
* \8 : Changes text color to "orange" range where supported.
* \9 : Changes text color to "yellow" range where supported.
* \N : Changes text color to gamemode "normal" range where supported.
* \H : Changes text color to gamemode "hilite" range where supported.
* \E : Changes text color to gamemode "error" range where supported.
* \S : Toggles text shadowing where supported.
* \C : Toggles absolute centering of text where supported.
 
If \ is followed by any other character, the slash is discarded and the next character is treated normally (ie, \d becomes d). Avoid doing this, however, to maintain forward compatibility.
 
Examples:
 
    thingtype w00t
    {
        obituary_normal = "w00ts"
        obituary_melee  = 'says \'w00t\''
    }
 
Line Continuation:
 
Starting with Eternity Engine v3.31 Delta, line continuation can be used to split quoted strings across multiple lines. The syntax for doing this is demonstrated in the following example:
 
    frame S_MYFRAME
    {
        cmp = "TROO|A|*|6 \
              TroopAttack|@next"
    }
 
The "\" character, when followed immediately by a line break, signifies that line continuation should be triggered. Whitespace before the line continuation will be included in the string, but any spaces or tabs at the beginning of the next line will NOT be included (this is the same as line continuation in BEX files). This allows the following continued parts of the string to be arbitrarily indented for purposes of beautification. A string can be split across any number of lines in this fashion.
 
===Numbers===
 
Most non-string fields in EDF are numbers, either integer or floating-point. Starting with EDF 1.1, decimal, octal, and hexadecimal integers will be accepted in all number fields. Octal numbers start with a zero, and hexadecimal numbers start with the sequence 0x -- Examples:
 
    # this is a normal, decimal number (base 10)
    spriteframe = 16
    ...
    # this is an octal number (base 8)
    spriteframe = 020
    ...
    # this is a hexadecimal number (base 16)
    spriteframe = 0x10
 
Floating-point numbers must have a decimal point in them, as in "20.0". Floating-point numbers are always base 10.
 
==Reserved Identifiers==
 
This section describes classes of identifiers (such as thing, frame, and sound mnemonics) which are considered reserved by the Eternity Engine. You should avoid using any identifier in the following classes for objects which you define yourself. Failure to do so could result in incompatibility of your project with future versions of the Eternity Engine due to conflicts with newly added game engine features.
 
* All identifiers beginning with _ (underscore)
* All identifiers beginning with EE or ee (this prefix means "Eternity Engine" and is therefore reserved for use by the source port's authors only).
* All identifiers containing ANY non-alphanumeric character excepting non-leading underscores (ex: $ is reserved).
 
For maximum safety, it is recommended that you develop a consistent and unique naming scheme for objects you create yourself. A simplistic example would be prefixing the word My to mnemonics, such as "MyNewThingType". Such names are more or less guaranteed to never conflict with anything defined by the game engine itself. The Chex Quest III project uses the prefix "CQ" for this purpose. As a side effect, this also improves the ability of your EDF patches to combine with those of others.
 
==Loading EDF==
 
EDF can be loaded either from an external file or from a WAD lump.
 
* To include EDF in a WAD file, the name of the root EDF lump must be "EDFROOT".
* To include an EDF file from the command line, use the -edf parameter. For example:
    eternity -edf c:\blah\root.edf
* The new [[GFS]] file can specify the root EDF file with the "edffile" keyword. Only one EDF file can be specified in a GFS. If -edf is used when a GFS is loaded, the command-line parameter will take precedence. See the GFS documentation for further information.

Latest revision as of 02:05, 30 April 2018