The syntax for each of the possible line types (comment, directive, instruction) is slightly different.
A comment is defined by a line of text proceeded by the pound ('#') key. For example:
# this is an example of a comment
Comments do nothing to the script and are ignored by the Pfhortran parser. They only exist to make it easier for another human being to decipher your code. It is a very good idea to comment all your source, as it will make it easier for you and others to quickly and easily make modifications in the future.
A directive must sit on a line by itself, and can have only one operand. All directives are proceeded with the underscore ('_') character. For example:
_report_errors true
This example turns on error reporting, which will help you debug your scripts. All procedures are defined with the _procedure directive (don't worry, we'll go into detail later).
Pfhortran instructions have the most complicated syntax. The syntax looks like this: ([] indicates an optional value)
[label:] instruction [operand 1,][operand 2,][operand 3] [# comment]
What this means in English is that each line may optionally have a single label followed by a colon preceding the instruction itself. Further, each instruction may have up to three operands, separated by commas. Finally, a comment may be placed after the instruction by using the pound symbol. The following are examples of valid instructions.
script_end
top: inflict_damage 3
wait_ticks 25 # wait 25 ticks...
set_camera_pos 23.211, -45.21, 0.6
jump: if_= x, y, top # jump to top if x = y
The first line is an example of the simplest possible instruction: it has no label and no operands... it just is. The second line uses a label (top) and a single operand (3) in conjunction with the instruction (inflict_damage ). The third line has a comment attached, and the fourth line displays the max of three floating point operators in application. Finally, the last line combines all five options to create an example of the most complicated kind of line Pfhortran can support: an instruction with a label and three operands, followed by a comment.
Don't worry if it seems confusing right now. When we start getting into actual script examples and the tutorial, it will make a lot more sense.
|