C# Class TeaseAI_CE.Scripting.VM

Main 'world' object, needs to know about all scripts, personalities, controllers, functions, etc..
Inheritance: IKeyed
Show file Open project: TeaseAI/TeaseAI-CE Class Usage Examples

Public Properties

Property Type Description
Punctuation char[]

Public Methods

Method Description
AddFunction ( System.Function func ) : void
AddFunction ( string name, System.Function func ) : void
ChangePersonalityID ( Personality p, string newID ) : bool
CreateController ( string id, Logger log = null ) : Controller

Creates a new controller for the given personality.

CreatePersonality ( string name ) : Personality

Craete a new personality with given name.

Get ( Key key, Logger log = null ) : Variable
GetAllControllers ( ) : TeaseAI_CE.Scripting.Controller[]
GetGroups ( ) : TeaseAI_CE.Scripting.GroupInfo[]
GetPersonalities ( ) : TeaseAI_CE.Scripting.Personality[]
GetScriptResponse ( string keyword ) : BlockBase
InputToShorthand ( string text ) : string

Runs text through input replace, to convert to shorthand.

KeyClean ( string key, Logger log = null ) : string

Removes white-space, sets lowercase, removes invalid characters, trims white-space.

KeyClean ( string keys, Logger log = null ) : string[]

Removes white-space, sets lowercase, removes invalid characters, trims white-space.

KeySplit ( string key ) : string[]
LoadFromDirectory ( string path ) : void

Load files in path and all sub directories.

QueryScript ( VType query, Logger log ) : Script
QueryScript ( Variable query, Logger log ) : Script
RemoveController ( Controller c ) : void
RunPersonalitySetup ( ) : void
SanitizeInputReplace ( string str ) : string

Sanitize a string for use in the input replace system.

SanitizeInputReplace ( string strings ) : string[]

Sanitize strings for use in the input replace system.

Start ( ) : void

Starts the controller update thread

Stop ( ) : void

Stop controller updating.

TryGetPersonality ( string name, Personality &p ) : bool
VM ( ) : System
Validate ( ) : void

Private Methods

Method Description
ExecLine ( Context sender, string line, StringBuilder output ) : void

Execute a line of code.

KeyClean ( string key, bool &isFloat, bool &isPercent, Logger log = null ) : string

Removes white-space, sets lowercase, removes invalid characters, trims white-space.

addScript ( string type, string rootKey, string key, Script script, string tags, string responses ) : void
execParenthCheckAdd ( Context sender, List items, StringBuilder sb ) : void

Check whats in sb, then add it to the list. [float, bool, and, or, variable]

execParentheses ( Context sender, string str, int &i ) : TeaseAI_CE.Scripting.Variable[]

Recursively parses and executes everything in the parentheses, then returns variable array.

execSplitCommand ( Context sender, string str, int &i, string &key, Variable &args ) : void

gets key and parentheses as args.

getFileLines ( string file, Logger &log ) : List

Gets all lines in file, returns null on IOException.

isNumberChar ( char c ) : bool
parseBlock ( List rawLines, int &currentLine, int blockIndent, Logger log ) : Line[]

Parses rawLines in to blocks of code recursively based on blockIndent.

parseBlockStart ( string str, string &key, List &args, Logger log ) : void
parseCutLine ( string &str, int &indentCount ) : bool

Counts indentation, and trims white-space and comments from str.

parseInputReplace ( List rawLines, Logger log ) : void

Parses rawLines as csv for the input replace system

parseScriptGroup ( List rawLines, string filePath, string fileKey, Logger fileLog ) : void

Parses raw lines in to the system.

parseStringArray ( string str, int &i, Logger log ) : string[]

Parse [] as an array of strings

parseStringQuoted ( string str, int &i, Logger log ) : string

Parse "" as a string

runAllSetupOn ( Controller c, StringBuilder sb ) : void

Runs all setup scripts on the controller.

runAllSetupOn ( Personality p, StringBuilder sb ) : void

Runs all setup scripts on the personality.

runThroughScript ( Controller c, BlockBase s, StringBuilder sb ) : bool

Add script to controller, call next until false.

threadTick ( ) : void

Updates all controllers.

validateScript ( Controller c, Script s, Variable>.Dictionary vars, StringBuilder output ) : void

Method Details

AddFunction() public method

public AddFunction ( System.Function func ) : void
func System.Function
return void

AddFunction() public method

public AddFunction ( string name, System.Function func ) : void
name string
func System.Function
return void

ChangePersonalityID() public method

public ChangePersonalityID ( Personality p, string newID ) : bool
p Personality
newID string
return bool

CreateController() public method

Creates a new controller for the given personality.
public CreateController ( string id, Logger log = null ) : Controller
id string
log Logger
return Controller

CreatePersonality() public method

Craete a new personality with given name.
public CreatePersonality ( string name ) : Personality
name string
return Personality

Get() public method

public Get ( Key key, Logger log = null ) : Variable
key Key
log Logger
return Variable

GetAllControllers() public method

public GetAllControllers ( ) : TeaseAI_CE.Scripting.Controller[]
return TeaseAI_CE.Scripting.Controller[]

GetGroups() public method

public GetGroups ( ) : TeaseAI_CE.Scripting.GroupInfo[]
return TeaseAI_CE.Scripting.GroupInfo[]

GetPersonalities() public method

public GetPersonalities ( ) : TeaseAI_CE.Scripting.Personality[]
return TeaseAI_CE.Scripting.Personality[]

GetScriptResponse() public method

public GetScriptResponse ( string keyword ) : BlockBase
keyword string
return BlockBase

InputToShorthand() public method

Runs text through input replace, to convert to shorthand.
public InputToShorthand ( string text ) : string
text string
return string

KeyClean() public static method

Removes white-space, sets lowercase, removes invalid characters, trims white-space.
public static KeyClean ( string key, Logger log = null ) : string
key string
log Logger
return string

KeyClean() public static method

Removes white-space, sets lowercase, removes invalid characters, trims white-space.
public static KeyClean ( string keys, Logger log = null ) : string[]
keys string
log Logger
return string[]

KeySplit() public static method

public static KeySplit ( string key ) : string[]
key string
return string[]

LoadFromDirectory() public method

Load files in path and all sub directories.
public LoadFromDirectory ( string path ) : void
path string
return void

QueryScript() public method

public QueryScript ( VType query, Logger log ) : Script
query VType
log Logger
return Script

QueryScript() public method

public QueryScript ( Variable query, Logger log ) : Script
query Variable
log Logger
return Script

RemoveController() public method

public RemoveController ( Controller c ) : void
c Controller
return void

RunPersonalitySetup() public method

public RunPersonalitySetup ( ) : void
return void

SanitizeInputReplace() public static method

Sanitize a string for use in the input replace system.
public static SanitizeInputReplace ( string str ) : string
str string
return string

SanitizeInputReplace() public static method

Sanitize strings for use in the input replace system.
public static SanitizeInputReplace ( string strings ) : string[]
strings string
return string[]

Start() public method

Starts the controller update thread
public Start ( ) : void
return void

Stop() public method

Stop controller updating.
public Stop ( ) : void
return void

TryGetPersonality() public method

public TryGetPersonality ( string name, Personality &p ) : bool
name string
p Personality
return bool

VM() public method

public VM ( ) : System
return System

Validate() public method

public Validate ( ) : void
return void

Property Details

Punctuation public static property

public static char[] Punctuation
return char[]