-
Notifications
You must be signed in to change notification settings - Fork 0
Parser
You can look into TextParser for additional help on using the parser in your games.
static int Parser.FindWordID(string wordToFind)
Looks up wordToFind in the text parser dictionary, and returns the ID number.
If the word is not found, returns -1.
Otherwise, the Word Group number is returned, as seen in the Text Parser
tab in the editor.
You can determine if two words are synonyms by looking them both up and seeing if the returned IDs are the same.
Ignore words are returned as ID 0.
This function is useful if you want to use the AGS Text Parser dictionary, but implement some custom parsing functionality instead of using the standard ParseText function.
Example:
if (Parser.FindWordID("machine") > 0)
{
Display("machine is in the game dictionary");
}
will display a message if the game dictionary includes "machine"
Compatibility: Supported by AGS 3.1.0 and later versions.
See Also: Parser.ParseText
static Parser.ParseText(string text)
Stores the supplied user text string for later use by Said. You need to call this command first with the user's input before using the Said command. You would usually call this inside the text box's OnActivate event handler.
Example:
String command = txtParser.Text;
Parser.ParseText(command);
will get the players input and store it in string "command" for use with the said command.
See Also: Parser.FindWordID, Parser.Said
static bool Parser.Said(string text)
Checks whether the player typed in TEXT in their input passed to ParseText. Returns true if it matches, false otherwise.
See the text parser documentation for a more detailed description.
Example:
String input = txtParserInput.Text;
Parser.ParseText(input);
if (Parser.Said("load")) {
txtParserInput.Text = "";
RestoreGameDialog();
}
will bring up the restore game dialogue if the player types "load" in the text parser.
See Also: Parser.ParseText, Parser.SaidUnknownWord
static String Parser.SaidUnknownWord()
If a word not in the game dictionary was submitted to the last ParseText call, then the word is returned by this command. This allows you to display a message like "Sorry, this game doesn't recognize 'XXXX'."
If all the words were recognized, this returns null.
Example:
String badWord = Parser.SaidUnknownWord();
if (badWord != null)
Display("You can't use '%s' in this game.", badWord);
will display the message if the player types a word that's not in the vocabulary.
See Also: Parser.ParseText, Parser.Said
Getting Started in AGS
Editor Reference
- Music and sound
- Distributing your game
- Backing up your game
- The text parser
- Translations
- Global variables
- Custom Properties
- Plugins
- Lip sync
- New Game templates
- Debugging features
- Auto-number speech files
- Integration with Windows
- Source Control integration
Engine
Scripting
- Scripting tutorial part 1
- Scripting tutorial part 2
- Pointers in AGS
- Calling global functions from local scripts
- The script header
- String formatting
- Multiple Scripts
- Understanding blocking scripts
- Dynamic Arrays
- Extender functions
- Game variables
- Predefined global script functions
- repeatedly_execute (_always)
- Custom dialog options rendering
- Built-in enumerated types
- Script language keywords
- AudioChannel functions and properties
- AudioClip functions and properties
- Character functions and properties
- DateTime functions and properties
- Dialog functions and properties
- DialogOptionsRenderingInfo functions and properties
- DrawingSurface functions and properties
- DynamicSprite functions and properties
- File functions and properties
- Game / Global functions
- GUI functions and properties
- GUI control functions and properties
- GUI Button functions and properties
- GUI InvWindow functions and properties
- GUI Label functions and properties
- GUI List Box functions and properties
- GUI Slider properties
- GUI Text Box functions and properties
- Hotspot functions and properties
- Inventory item functions and properties
- Maths functions and properties
- Mouse functions and properties
- Multimedia functions
- Object functions and properties
- Overlay functions and properties
- Palette functions
- Parser functions
- Region functions and properties
- Room functions
- Screen functions
- Speech functions and properties
- String functions
- System functions and properties
- Text display / Speech functions
- ViewFrame functions and properties
Working on Legacy games
Upgrading from a previous version
- Upgrading to AGS 2.7
- Upgrading to AGS 2.71
- Upgrading to AGS 3.0
- Upgrading to AGS 3.1
- Upgrading to AGS 3.2
- Upgrading to AGS 3.3
- Upgrading to AGS 3.3.5
- Upgrading to AGS 3.4
- Upgrading to AGS 3.4.1
Legal Notice
Getting in touch