Home Memoirs of a Gamer Movies I watched Guidebook Code Projects Links

The Gorgon Engine

The Said Instruction

This is probably the most complicated instruction in the engine and acts as the focal point of most functionality. The said instruction is how the game tests user commands entered at the command prompt. The most common use will be as a parameter to an if statement or if block.

if (said "[look(at)|around/room]/[$look]")
  msgbox "You are standing in a small room."
elseif (said "look(at)|man")
  msgbox "There is a man here and he looks grumpy."
elseif (said "take|pipe")
  item.add ITEM_PIPE
endif

Internally the said routine breaks apart the command into tokens and then recursively compares the tokens in order against the test string provided. There are a handful of operators that will inform said how acceptable sentences can be structured and each operator has a priority.

Operator by Priority

$ - dollar sign

The dollar sign is used to mark a word as being alone. Under normal circumstances, said will only test the number of words expected by the test string. Anything the user types in past the last tested word is effectively ignored. This means if you want to break up your said event by types of commands, like say by "look";"take";"push"; and "pull", your script can have each of those blocks start with their respective if clause wrapped around nested if blocks for the specific possible options for each. This practice does offer a much faster response on slower computers as the said instruction can be quite CPU intensive.

if (said "look")
  ::This will run if the player input
  ::starts with the word "look".
  if (said "$look")
    ::This will only run if the player
    ::only typed in the word "look"
    ::on it's own.
  elseif (said "look|room")
    ::This will only run if the player
    ::typed in "look room" and will
    ::ignore any words entered past
    ::the word "room".
  endif
endif
| - pipe character

Pipe characters are used to separate words that follow each other consecutively.

if (said "look|around|room")
  ::This will run if the player input
  ::at least starts with the phrase
  ::"look around room"
endif
/ - forward slash character

The forward slash marks multiple words as being allowed to occupy the same space in the target sentence.

if (said "take|tool/wrench/spanner/craftsman")
  ::This will run if the player input
  ::starts with "take tool", "take wrench",
  ::"take spanner", or "take craftsman".
endif
[] - square bracket characters

Square brackets are used to mark a phrase block that can take the same space as another word or block without having to share sentence structure.

if (said "ask|man/[business|man]/suit|about|cabbage")
  ::This will run if the player input
  ::follows the pattern "ask man about cabbage",
  ::"ask business man about cabbage" and
  ::"ask suit about cabbage" BUT will NOT
  ::run if the player typed in "ask suit man about cabbage"
endif
() - parenthesis characters

Parenthesis are used to mark a word as optional. This can be useful for allowing prepositions that may or may not be absolutely necessary for an intelligible sentence.

if (said "look(at)|man")
  ::This will run if the player input
  ::starts with "look at man" or "look man".
endif

Remember that the parser reads all acceptable words at initialization of the engine from the DICTION.DAT file. Any word tested for in your script files MUST BE in that dat file. The engine will not analyze acceptable words just from analysis of your script files themselves.