Lesson 1: In which we find out how to make dialogue and gameflow scripts


For making little APE games, you usually start by defining a window and its contents. To do so, you define the size, font to use, and so on. Almost all subfields present below are optional, and will correctly default to nice values if not specified. However, in most cases we're going to want to be pretty specific for most of the windows--you want to know what area you have to work with 90% of the time.


Entries: Windows and Switches
Gameflow scripts consist of two distinct types of discrete entries:

WINDOWS are dialogue boxes that pop up, usually with text, a title, a graphical border, a background graphic, and occasionally a list of choices. They typically stay open until dismissed (either clicked away or a choice is made). They can have conditional content based on variables set outside the window definition. This is not a program, but something that defines what is displayed. SWITCHES are "nodes" which control the logical flow of script execution. They are executed in an instant, unlike Windows which stay open while they are waiting for user input, etc. Switches can be used not only for doing intelligent window selection but also for any sort of event control between just about any plugin/module of Anachronox (including Battle events, shops, stats, camera scripts, actors scripts, you name it).
Windows can have a startfunction (which sets up variables before the window is drawn, a thinkfunction (which runs actively and can change, through variables, what the window draws), and a finishfunction (which cleans up anything that needs cleaning up, and may pass on global variables to be saved in the save file later). Rules, formats, and examples for using both types of gameflow entries can be found below. You can have as many windows and switches in a file as you want.

Specifying BANK:ENTRY numbers
Each entry - whether it be a Window or Switch - must have a unique identifier associated with it for flow control. This identifier is given in the form of two numbers seperated by a colon, such as "30:4". This example means "bank 30, entry 4", which is very much like saying "chapter 30, verse 4". The range for BANK is from (1 to 200,000); the range for ENTRY is (1 to 9,899). Anachronox, for the most part, uses banks 1 to 200.

The compiler actually generates a single ID number for each entry based on on the following formula: ID = (BANK * 10000) + ENTRY. The #:# format is merely for user-organizational purposes. Entry "0:0" is reserved to mean "no action", or "end of flow" (so you can say "goto 0:0", but you can never define your own "#window 0:0"). NOTE: It has become the unofficial convention to use one bank number per map (or per sub-map area), and not to divide banks across maps. Also, it is standard practice to always use a four digit entry number, where the first two digits identify the actor and the last two are used for uniqueness. For instance, "14:0302" might be "map #14" (whichever one that may be), "npc #3", "second dialogue". Examples in this file follow these standards.

(For personal APE game use, one should use a bank number of 50000 and up. For temporary use, you can use the bank number of 2, but you cannot be assured of it not getting trampled on. This is often used for testing purposes. Anyway, back to our discussion.)

Let's learn our first GameFlow command. It's called "body" Body defines what text we want printed in the window. We'll learn more about it later, but here's a simple window definition:

#window 1:1
body "Hello world."

So, if you compiled this file, loaded it into Anachronox, and invoked that window, you'd see "Hello world." printed in a default Anachronox GameFlow window.

What? You want to do that? Well, then, go to the MS-DOS prompt and go to the directory where Anachronox is installed.

Go to /ANOXDATA\GAMEFLOW/. Here is where the scripts are. Create a standard text file named lesson1.txt and copy the above program code into it.

So, to compile a script's text file, you type: "..\..\dparse <FILENAME>". You don't have to add the .TXT, because it knows it has to be a text file. And, of course, FILENAME is whatever name you want to use. This file's name is called "LESSON1". Dparse is located in your Anachronox root directory the command above uses the relative path to dparse from the directory we are currently in. You can also use the full pathname if you want, e.g. "c:\anox\dparse <filename>".

After you compile a file, assuming there are no errors in it, APE will create a file called FILENAME.APE. In this case it will result in "LESSON1.APE".

To run the file, launch Anachronox. Wait for the logo to appear. Press ALT+SHIFT+F10 , then the "~" to bring down the console.
Type:
map battlesize
(To see a window, a map must be loaded, and this is the smallest map.)

Now type:
loadape lesson1
The LOADFLO command will also load in any compiled APE file. You can load any number of APE files in at the same time. This command is the same as loadape.

Now type:
invoke 1:1
This will start the window.
Press "~" again to get rid of the console.
There is your window! It uses the default font, the default background, and the default window frame. How do we change those? Read on in LESSON2.TXT!