|
|
@ -27,7 +27,12 @@ namespace Fungus |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Called when the LuaEnvironment is initializing. |
|
|
|
/// Called when the LuaEnvironment is initializing. |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public abstract void Initialize(); |
|
|
|
public abstract void Initialize(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Applies transformations to the input script prior to execution. |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public abstract string PreprocessScript(string input); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
@ -216,11 +221,22 @@ namespace Fungus |
|
|
|
{ |
|
|
|
{ |
|
|
|
InitEnvironment(); |
|
|
|
InitEnvironment(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string processedString; |
|
|
|
|
|
|
|
Initializer initializer = GetComponent<Initializer>(); |
|
|
|
|
|
|
|
if (initializer != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
processedString = initializer.PreprocessScript(luaString); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
processedString = luaString; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Load the Lua script |
|
|
|
// Load the Lua script |
|
|
|
DynValue res = null; |
|
|
|
DynValue res = null; |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
res = interpreter.LoadString(luaString, null, friendlyName); |
|
|
|
res = interpreter.LoadString(processedString, null, friendlyName); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (InterpreterException ex) |
|
|
|
catch (InterpreterException ex) |
|
|
|
{ |
|
|
|
{ |
|
|
|