Invoking a GPDL Program

DungeonCraft Help Home



During gameplay, a GPDL function is invoked by special text in a text event. This method may seem a bit strange but, like the human appendix, it has a reason that can only be discovered by study of ancient history.

There are three ways of invoking a GPDL script as part of a text event. All employ the reserved characters "**SHAZAM" as the first eight characters of the text to initiate the process of replacing the text with a script:



Method 1 – the classic method.



In this method, the script resides in a file named "talk.bin" which has been previously compled from a text tile named "talk.txt". If no file named "talk.bin" exists, the engine will look for a file named "talk.txt" and, if found, will compile it internally and use the results of that compiliation. The event text begins as "**SHAZAM**<function name>(<parameters>)"/

The 'talk.bin" file can contain many different funtions and the particular function to be executed is defined in the SHAZAM text, along with the funtion's parameters. For example, assume the desired funtion is named "HalfwayHouse" and the required parameter is "Night". Then the evevnt text should begin as follows:

**SHAZAM**HalfwayHouse(Night)Offer the traveler a bed for the night.

Note that any text following the closing parenthesis is simply a comment and takes no part in the script selection or execution.



Method 2 – Script in arbitrary file



In this method, the event text names a file that contains the wcript. The file name must begin with "talk" but also contains a suffix that is supplied by the SHAZAM text. The text event begins as "**SHAZAM<suffix>**. For example, assume the script in contained in a file named "talkTavern"

and the function to be execited is "Drink" with parmeter "beer".

Then the event text would start:

**SHAZAMTavern**Drink(beer) Offer the weary traveler a pint

The engine first looks for a file named "talkTavern.bin" and if found uses it. If not found, the engine looks for a file named "talkTavern.txt" and if found compiles the file internally and uses the result of the compilation. In either case it executes a function named "Drink" with parameter "beer".



Note that any text following the closing parenthesis is simply a comment and takes no part in the script selection or execution.



Note that Method 1 is simply a special case of Method 2 in which the suffiz is empty;

Method 3 – Script contained within text event itself



In this method the script is contained withing the event text. The eventtext might look like this:



**SHAZAM**Greet()
$PUBLIC $FUNC Greet()
{
  $SAY("Good Morning");
} Greet;



In this case the function to be executed is named "Greet" and has no parameters.