PixelCrushers.DialogueSystem.Lua Class Reference

A static class that provides a global Lua virtual machine. More...

Collaboration diagram for PixelCrushers.DialogueSystem.Lua:

Classes

struct  Result
 Stores a Lua interpreter result (LuaValue) and provides easy conversion to basic types. More...
 

Static Public Member Functions

static Result Run (string luaCode, bool debug, bool allowExceptions)
 Runs the specified luaCode. More...
 
static Result Run (string luaCode, bool debug)
 Runs the specified luaCode. More...
 
static Result Run (string luaCode)
 Run the specified luaCode. More...
 
static bool IsTrue (string luaCondition, bool debug, bool allowExceptions)
 Evaluates a boolean condition defined in Lua code. More...
 
static bool IsTrue (string luaCondition, bool debug)
 Evaluates a boolean condition defined in Lua code. More...
 
static bool IsTrue (string luaCondition)
 Evaluates a boolean condition defined in Lua code. More...
 
static Language.Lua.LuaValue RunRaw (string luaCode, bool debug, bool allowExceptions)
 Runs Lua code and returns an array of return values. More...
 
static Language.Lua.LuaValue RunRaw (string luaCode, bool debug)
 Runs Lua code and returns an array of return values. More...
 
static Language.Lua.LuaValue RunRaw (string luaCode)
 Runs Lua code and returns an array of return values. More...
 
static void RegisterFunction (string functionName, object target, MethodInfo method)
 Registers a C# function with the Lua interpreter so it can be used in Lua. More...
 
static void UnregisterFunction (string functionName)
 Unregisters a C# function. More...
 

Static Public Attributes

static readonly Result NoResult = new Result(null)
 

Properties

static bool WasInvoked [get, set]
 Lua.RunRaw sets this Boolean flag whenever it's invoked. More...
 
static bool MuteExceptions [get, set]
 Set true to not log exceptions to the Console. More...
 
static bool WarnRegisteringExistingFunction [get, set]
 Set true to log warnings if trying to register a function under a name that's already registered. More...
 
static Language.Lua.LuaTable Environment [get]
 Provides direct access to the Lua Interpreter environment. More...
 

Detailed Description

A static class that provides a global Lua virtual machine.

This class provides a layer of abstraction between the low level Lua implementation (in this case LuaInterpreter) and the Dialogue System.

Member Function Documentation

◆ IsTrue() [1/3]

static bool PixelCrushers.DialogueSystem.Lua.IsTrue ( string  luaCondition)
static

Evaluates a boolean condition defined in Lua code.

The code is not logged to the console, and exceptions are ignored.

Returns
true if luaCode evaluates to true; otherwise, false
Parameters
luaConditionThe conditional expression to evaluate. Do not include "return" in front.

◆ IsTrue() [2/3]

static bool PixelCrushers.DialogueSystem.Lua.IsTrue ( string  luaCondition,
bool  debug 
)
static

Evaluates a boolean condition defined in Lua code.

Exceptions are ignored.

Returns
true if luaCode evaluates to true; otherwise, false
Parameters
luaConditionThe conditional expression to evaluate. Do not include "return" in front.
debugIf true, logs the Lua command to the console.

◆ IsTrue() [3/3]

static bool PixelCrushers.DialogueSystem.Lua.IsTrue ( string  luaCondition,
bool  debug,
bool  allowExceptions 
)
static

Evaluates a boolean condition defined in Lua code.

Returns
true if luaCode evaluates to true; otherwise, false.
Parameters
luaConditionThe conditional expression to evaluate. Do not include "return" in front.
debugIf true, logs the Lua command to the console.
allowExceptionsIf true, exceptions are passed up to the caller. Otherwise they're caught and ignored.

if (Lua.IsTrue("height > 6")) { ... }

◆ RegisterFunction()

static void PixelCrushers.DialogueSystem.Lua.RegisterFunction ( string  functionName,
object  target,
MethodInfo  method 
)
static

Registers a C# function with the Lua interpreter so it can be used in Lua.

Parameters
pathThe name of the function in Lua.
targetTarget object containing the registered method. Can be null if a static method.
functionThe method that will be called from Lua.

◆ Run() [1/3]

static Result PixelCrushers.DialogueSystem.Lua.Run ( string  luaCode)
static

Run the specified luaCode.

The code is not logged to the console, and exceptions are ignored.

Parameters
luaCodeThe Lua code to run. Generally, if you want a return value, this string should start with "return".

◆ Run() [2/3]

static Result PixelCrushers.DialogueSystem.Lua.Run ( string  luaCode,
bool  debug 
)
static

Runs the specified luaCode.

Exceptions are ignored.

Parameters
luaCodeThe Lua code to run. Generally, if you want a return value, this string should start with "return".
debugIf set to true, logs the Lua command to the console.

◆ Run() [3/3]

static Result PixelCrushers.DialogueSystem.Lua.Run ( string  luaCode,
bool  debug,
bool  allowExceptions 
)
static

Runs the specified luaCode.

Returns
A Result struct from which you can retrieve basic data types from the first return value.
Parameters
luaCodeThe Lua code to run. Generally, if you want a return value, this string should start with "return".
debugIf true, logs the Lua command to the console.
allowExceptionsIf true, exceptions are passed up to the caller. Otherwise they're caught and ignored.

float myHeight = Lua.Run("return height").asFloat;

◆ RunRaw() [1/3]

static Language.Lua.LuaValue PixelCrushers.DialogueSystem.Lua.RunRaw ( string  luaCode)
static

Runs Lua code and returns an array of return values.

Does not log to console and ignores exceptions.

Returns
An array of return values, or null if the code generates an error.
Parameters
luaCodeThe Lua code to run. If you want a return value, this string should usually start with "<c>return</c>".

◆ RunRaw() [2/3]

static Language.Lua.LuaValue PixelCrushers.DialogueSystem.Lua.RunRaw ( string  luaCode,
bool  debug 
)
static

Runs Lua code and returns an array of return values.

Ignores exceptions.

Returns
An array of return values, or null if the code generates an error.
Parameters
luaCodeThe Lua code to run. If you want a return value, this string should usually start with "<c>return</c>".
debugIf true, logs the Lua command to the console.

◆ RunRaw() [3/3]

static Language.Lua.LuaValue PixelCrushers.DialogueSystem.Lua.RunRaw ( string  luaCode,
bool  debug,
bool  allowExceptions 
)
static

Runs Lua code and returns an array of return values.

Returns
An array of return values, or null if the code generates an error.
Parameters
luaCodeThe Lua code to run. If you want a return value, this string should usually start with "<c>return</c>".
debugIf true, logs the Lua command to the console.
allowExceptionsIf true, exceptions are passed up to the caller. Otherwise they're caught and logged but ignored.

◆ UnregisterFunction()

static void PixelCrushers.DialogueSystem.Lua.UnregisterFunction ( string  functionName)
static

Unregisters a C# function.

Parameters
functionNameFunction name.

Member Data Documentation

◆ NoResult

readonly Result PixelCrushers.DialogueSystem.Lua.NoResult = new Result(null)
static

Property Documentation

◆ Environment

Language.Lua.LuaTable PixelCrushers.DialogueSystem.Lua.Environment
staticget

Provides direct access to the Lua Interpreter environment.

The Interpreter environment.

◆ MuteExceptions

bool PixelCrushers.DialogueSystem.Lua.MuteExceptions
staticgetset

Set true to not log exceptions to the Console.

true if mute exceptions; otherwise, false.

◆ WarnRegisteringExistingFunction

bool PixelCrushers.DialogueSystem.Lua.WarnRegisteringExistingFunction
staticgetset

Set true to log warnings if trying to register a function under a name that's already registered.

◆ WasInvoked

bool PixelCrushers.DialogueSystem.Lua.WasInvoked
staticgetset

Lua.RunRaw sets this Boolean flag whenever it's invoked.

true when Lua.RunRaw is invoked.


The documentation for this class was generated from the following file: