Browse Source

Added Preprocessor support for LuaEnvironment / LuaUtils

master
Christopher 9 years ago
parent
commit
4c786232d8
  1. 20
      Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs
  2. 8
      Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs

20
Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs vendored

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

8
Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs vendored

@ -95,6 +95,14 @@ namespace Fungus
InitBindings();
}
/// <summary>
/// Called by LuaEnvironment prior to executing a script.
/// </summary>
public override string PreprocessScript(string input)
{
return input;
}
/// <summary>
/// Registers all listed c# types for interop with Lua.
/// You can also register types directly in the Awake method of any

Loading…
Cancel
Save