2015-07-02 00:17:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2016-01-31 00:37:30 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2015-07-02 00:17:15 +00:00
|
|
|
|
using LuaInterface;
|
|
|
|
|
|
2016-01-30 20:26:02 +00:00
|
|
|
|
namespace BizHawk.Client.Common
|
2015-07-02 00:17:15 +00:00
|
|
|
|
{
|
2016-01-31 00:37:30 +00:00
|
|
|
|
public class LuaSandbox
|
2015-07-02 00:17:15 +00:00
|
|
|
|
{
|
|
|
|
|
protected static Action<string> Logger;
|
|
|
|
|
|
|
|
|
|
public static void SetLogger(Action<string> logger)
|
|
|
|
|
{
|
|
|
|
|
Logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Sandbox(Action callback, Action exceptionCallback = null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
EnvironmentSandbox.Sandbox(callback);
|
|
|
|
|
}
|
|
|
|
|
catch (LuaException ex)
|
|
|
|
|
{
|
|
|
|
|
Logger(ex.ToString());
|
|
|
|
|
if (exceptionCallback != null)
|
|
|
|
|
{
|
|
|
|
|
exceptionCallback();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|