-
Notifications
You must be signed in to change notification settings - Fork 10
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
- New Game templates
- Editor Preferences
- General Settings
- Default Setup
- Colours Editor
- Room Editor
- Character Editor
- Cursor Editor
- Dialog Editor
- Font Preview
- GUI Editor
- Inventory Items Editor
- View Editor
- Sprite Manager
- Music and sound
- Voice speech
- Script Modules
- System limits
- Log Panel
- Plugins
- Other Features
Engine
Scripting
- Scripting Tutorial
- Scripting Language
-
Scripting API
- Script API Overview
- Standard Constants
- Standard Enumerated Types
- Standard Types
- Game variables
- Global arrays
- Global event handlers
- repeatedly_execute / repeatedly_execute_always
- Custom dialog options rendering
- Global functions: general
- Global functions: message display
- Global functions: multimedia actions
- Global functions: palette operations
- Global functions: room actions
- Global functions: screen effects
- Global functions: wait
- AudioChannel functions and properties
- AudioClip functions and properties
- Camera functions and properties
- Character functions and properties
- DateTime functions and properties
- Dialog functions and properties
- DialogOptionsRenderingInfo functions and properties
- Dictionary functions and properties
- DrawingSurface functions and properties
- DynamicSprite functions and properties
- File functions and properties
- Game functions and properties
- 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
- Object functions and properties
- Overlay functions and properties
- Parser functions
- Region functions and properties
- Room functions and properties
- Screen functions and properties
- Set functions and properties
- Speech functions and properties
- String functions
- System functions and properties
- TextWindowGUI functions and properties
- ViewFrame functions and properties
- Viewport functions and properties
- Obsolete Script API
- Event Types
- Key code table
- Audio in script
Legal Notice
Getting in touch
Misc
Hidden