PowerQuest 0.20.6
Loading...
Searching...
No Matches
IParser Interface Reference

Detailed Description

Parser: Contains functions for text parser commands. See Parser Scripting

if ( Parser.Said("Look at lamp") )
    Display: It's a lamp

Properties

bool HasTarget [get]
 Returns true if there was a "target" in the parsed text from the Said() function.
 
IQuestClickable Target [get]
 Returns a "target" from the Said() function.
 
string Text [get]
 Property to get the last text passed into the ParseText() function.
 
bool HasUnknownWord [get]
 Returns true if the last parsed text had an unrecognised word.
 
string UnknownWord [get]
 Returns any unrecognised word in the last parsed text.
 
bool HasWildcard [get]
 Returns true if there's a wildcard word (*) in the parsed text.
 
string WildcardWord [get]
 Returns what was matched as a wildcard word (*) in the parsed text.
 

Public Member Functions

void ParseText (string input, bool callOnParserScripts=true)
 Triggers a parser command typed in by the player. Usually called from a gui, after they've typed in something and press Enter.
 
void RunParserScripts ()
 Initiates "OnParser" functions being called. Usually done automatically when ParseText() is called.
 
bool Said (string query)
 Use this to check whether the player's input matches what you want. If it does, it returns true. For info see Parser Scripting
 
bool Said (string query, IQuestClickableInterface target)
 Use this to check whether the player's input matches what you want, with a specified Quest Object. If it does, it returns true. For info see Parser Manual- Special Character, under Quest Objects.
 
void OnUnhandledEvent ()
 Call this if a line was not handled, it will copy the line to clipboard for pasting into your script if you want to add it, and save out a list of what people typed too. See Parser Manual- Unhandled input
 

Property Documentation

◆ HasTarget

bool HasTarget
get

Returns true if there was a "target" in the parsed text from the Said() function.

See also
Said
Target

◆ Target

IQuestClickable Target
get

Returns a "target" from the Said() function.

See also
Said
HasTarget For more info, see Parser Manual- Special Character, under Quest Objects

Eg.

if ( Parser.Said("Lift", H.Boulder) || Parser.Said("Lift", P.Elephant) )
{
    Plr.Face( Parser.Target );
    Dave: The {Parser.Target.Description} is too heavy.
}

◆ Text

string Text
get

Property to get the last text passed into the ParseText() function.

◆ HasUnknownWord

bool HasUnknownWord
get

Returns true if the last parsed text had an unrecognised word.

eg.

if ( Parser.HasUnknownWord ) 
    Display: You can't use the word {Parser.UnknownWord} here!
See also
UnknownWord
Said

◆ UnknownWord

string UnknownWord
get

Returns any unrecognised word in the last parsed text.

eg.

if ( Parser.HasUnknownWord ) 
    Display: You can't use the word {Parser.UnknownWord} here!
See also
HasUnknownWord
Said

◆ HasWildcard

bool HasWildcard
get

Returns true if there's a wildcard word (*) in the parsed text.

eg.

if ( Parser.HasWildcard )
    Display: What on earth is a {Parser.WildcardWord}?
See also
Said
WildcardWord

◆ WildcardWord

string WildcardWord
get

Returns what was matched as a wildcard word (*) in the parsed text.

See Parser Manual- Special Characters

eg.

if ( Parser.Said("Sit on *") )
    Display: You sit on the {Parser.WildcardWord}
See also
Said
HasWildcard

Member Function Documentation

◆ ParseText()

void ParseText ( string input,
bool callOnParserScripts = true )

Triggers a parser command typed in by the player. Usually called from a gui, after they've typed in something and press Enter.

By default RunParserScripts() is called automatically- which calls through to your OnParser commands. Pass "false" if you want to trigger this manually.

See also
RunParserScripts

◆ RunParserScripts()

void RunParserScripts ( )

Initiates "OnParser" functions being called. Usually done automatically when ParseText() is called.

See also
ParseText

◆ Said() [1/2]

bool Said ( string query)

Use this to check whether the player's input matches what you want. If it does, it returns true. For info see Parser Scripting

Eg.

if ( Parser.Said("Say Hello") )
{
    Dave: Hello!
}
else if ( Parser.Said("Talk Barney") )
{
    Dave: Hi Barney.
    Barney: Hi!
}

The parser template games have a bunch of shortcuts for using this- like: ~~ say hello~

◆ Said() [2/2]

bool Said ( string query,
IQuestClickableInterface target )

Use this to check whether the player's input matches what you want, with a specified Quest Object. If it does, it returns true. For info see Parser Manual- Special Character, under Quest Objects.

  • Often you want to match hotspots, props, characters, or inventory items that are in the game. Especially if you're mixing mouse and parser support.
  • This is possible with a second parameter to the IParser.Said() function. Eg. Parser.Said("drink from", H.Well);
  • For info see 'Parser Scripting', under Quest Objects
  • When doing this, the parser will match the text in the description of the object, which also supports the , character.
    • So if the Well prop's description is "well, hole", the above example will match "drink from hole" or "drink from well".
  • This also means WalkToClicked and FaceClicked will work.
  • You also can access this 'clickable object' object with Parser.Target.

Eg. if ( Parser.Said("drink from", H.Well) ) { Display: You take a drink from the well } else if ( Parser.Said("Talk"), C.Barney ) { Dave: Hi Barney. Barney: Hi! }

The parser template games have a bunch of shortcuts for using this- like: ~~ say hello~

See also
HasTarget
Target

◆ OnUnhandledEvent()

void OnUnhandledEvent ( )

Call this if a line was not handled, it will copy the line to clipboard for pasting into your script if you want to add it, and save out a list of what people typed too. See Parser Manual- Unhandled input