DEdit – Database Editor

Documentation version 1.0 , 2009-11-21


Description Tutorial 2: Advanced databases

This tutorial will explain some of the more advanced concepts of description databases. It is assumed that you know how to create, save and navigate simple databases. If not, do the tutorial 1 first. This tutorial is no longer in step-by-step style, but rather explains the different subjects with examples. Nevertheless you should read it from top to bottom the first time. Try the given examples.
Once you have mastered simple scripting you might be interested in advanced scripting in tutorial 3.

Simple scripting commands – syntax highlighting

DEdit descriptions are more than pure text. They can contain commands which will be interpreted by the generation algorithm. All commands begin with a $ character, which is the reason why you should not use that in your descriptions. This tutorial will explain the most simple commands $Random , $OneOf , $Direct , $DB , $Menu and $Fill. The first five of them can be accessed directly by buttons, as they are used most often.

At the bottom of the interface you find the Options button. Click on it to set options for Syntax highlighting. Here you can set, how the text in the textfields of the editor should be displayed and - if syntax highlighting is enabled - set the colours for the highlighted text parts.

Output-preview

To give you an idea, what the final results of your scripted descriptions will be, you can always press the F4 – button. As long as you keep it pressed, DEdit will display a ‘generated output’ of your description. (Executing all commands.) While the preview is activated, you can not alter the entry. Note further, that the F4 preview does not work, if more than one TavernMaker program (DEdit.exe, TavernMaker.exe) is opened at the same time.

 $Random

The $Random command can be used at any place of text. If you place your cursor anywhere in the text and then click on the $Random button on top of the text-area, it will be inserted automatically. Alternatively, you can type it.

 

The syntax of the command is $Random{min,max} whereas min and max define a minimum and a maximum number. When executed, the command will be replaced by a random number within the defined range. $Random{3,10} will therefore create a random number between 3 and 10. You can only get integer numbers (no commas).
If you use $Random with just one number it will generate a random number 'around' that number (lower or higher by 10%), e.g. $Random(50) will produce a random nuber between 45 and 55.

 

examples:

output:

alternative output:

$OneOf

The $OneOf command can be used at any place of text. If you place your cursor anywhere in the text and then click on the $OneOf button on top of the text-area, it will be inserted automatically. Alternatively, you can type it.

 

The syntax of the command is $OneOf{<>,<>,...} where each <> stands for and alternative string. When executed, the command will be replaced by one of the given possibilities. $OneOf{<green>,<red>,<blue>} will therefore create either green , red or blue. You can uses as many alternatives as you want, all enclosed in < > brackets and separated by commas.

 

examples:

output:

alternative output:

$Direct

The $Direct command can be used at any place of text. If you place your cursor anywhere in the text and then click on the $Direct button on top of the text-area, it will be inserted automatically. Alternatively, you can type it.

 

The syntax of the command is $Direct{<>,chance,min,max} where <> stands for a string, chance for a chance in % that the text appears and min/max for a minimum and maximum value. When executed, the command will check against chance and display the string, if the check is positive. You can use the command to add attributes which might appear, but don’t have to. The $Direct command also includes the $Random command. Wherever you place a %i within the string, it will be replaced by a random number between min and max. Each %i will be replaced by a different random value.

 

Some $Direct-commands are predefined. On top of the text-area you find the Add $Direct button and some drop-down lists and number boxes left of it. The Add $Direct button is the top of three buttons, and the top of the drop-downs as well as the number boxes are associated with it. You can select one entry of the drop-down (e.g. %i / %i copper coins), enter a %-value and two number in the two count boxes. Then position the cursor somewhere in the text area and click the Add $Direct button.

 

examples:

output:

alternative output:

Combined commands

All commands can be combined and encapsulated. Just be careful with the brackets! Syntax highlighting helps you to keep your orientation, by colouring the brackets depending on their hierarchy.

 

examples:

output:

alternative output:

$Fill & race flag fill

The $Fill command can be used at any place of text. It can be used to create descriptions where the number of persons is not fixed beforehand but is defined by the table-icon of the generated map. The command works hand in hand with the fill flag at the race flags. In the race flags one race can be set to ‘fill’ by selecting it and pressing the Fill button. The flag will get an * character within the { }brackets to mark its fill-status. The count gets an additional + fill. The concept is best explained with an example.

 

examples:

 

For the text-generation algorithm this entry counts as an entry with minimum 3 persons (The fill flag automatically counts as 2 to avoid problems with singular/plural) and can therefore be used at any table with 3 or more seats.

If it is used on a table-icon which has 5 seats, the fill flag would count as 4,.

If it is used on a table-icon with 3 seats, the fill flag would count as 2.

The $Fill command in the descriptions would be replaced by 4 or 2, respectively.  The above example would therefore produce “At this table sit 2 humans together with a dwarf” at the 3-seats-table and “At this table sit 4 humans together with a dwarf” at the 5-seats-table.

When previewing the description by pressing F4, the program takes a random number instead of $Fill, because there is no table-icon.

$DB – PPitem databases

The $DB command can be used at any place of text. If you place your cursor anywhere in the text and then click on the $DB button on top of the text-area, it will be inserted automatically. Alternatively, type it.

A much more convenient way, however, is to use the $DB drop-down list above the text area and use the Add $DB button to place the command at the current cursor position. First select the main type (left of the two drop-downs), e.g. weapon. Next use the second (right) drop-down to select one of the available subtypes (e.g. knife). Then enter a chance and a minimum and maximum value. Click somewhere in the text-area to place the cursor. Click on the  Add $DB button to add the command..

 

The syntax of the command is $DB{<>,<type>, chance, min, max } whereas <> stands for an output string, <type> for a type string, , chance for a chance in % that the text appears and min/max for a minimum and maximum value.

 

When executed, the command will select a random entry from all available PPitem-databases. If any is found, the command will check against chance and display the string, if the check is positive. Any %i within the string will be replaced by a random number in the range of min to max like in the $Direct command. Any %s will be replaced by the short text of the selected item-entry and every %l by the long text of the item-entry. 

 

An example will make things more clearly.

 

examples:

 

When executed, there is a 50% chance that the text The man carries a... appears. All PPItem databases are searched for entries of the type weapon/knife and from those found one is randomly selected. It’s short text is used instead of the %s and the long text instead of the %l, so that the complete description may read like:

 

output:

alternative output:

 

This should demonstrate the huge advantage of $DB and PPItem databases. Descriptions will be very different every time, and other people can extend the PPItem database later on to add more possibilities...

The main idea of the PPItem databases is to use them in the pickpocket list. (Thus, they are called pickpocket-item databases or PPItem) Instead of writing what can be stolen from each table, one can use a lot of $DB commands and the additional databases guarantee for a huge variety. To learn more about PPItems follow the PPItems introduction and tutorials.

 

examples for a pick-pocket list:

output:

alternative output:

$Menu

This command is not yet implemented. It will work similar to the $DB command, but uses the generated menu of the tavern as source file, so that it is possible to used meals in the description, which do also appear on the randomly generated menu.

 

Some more examples

examples:

output:

alternative output: