本文整理汇总了C#中LuaInterface.Lua.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Lua.Close方法的具体用法?C# Lua.Close怎么用?C# Lua.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaInterface.Lua
的用法示例。
在下文中一共展示了Lua.Close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunLua
private void RunLua(object obj)
{
try
{
string luaFile = obj as string;
Lua luaVM = new Lua();
luaVM.RegisterFunction("FMSignal", this, this.GetType().GetMethod("FMSignal"));
luaVM.RegisterFunction("Single", this, this.GetType().GetMethod("Single"));
luaVM.RegisterFunction("Output", this, this.GetType().GetMethod("Output"));
luaVM.RegisterFunction("OutputLine", this, this.GetType().GetMethod("OutputLine"));
luaVM.RegisterFunction("Sleep", this, this.GetType().GetMethod("Sleep"));
luaVM.RegisterFunction("SetAcVolt", this, this.GetType().GetMethod("SetAcVolt"));
luaVM.RegisterFunction("SetDcVolt", this, this.GetType().GetMethod("SetDcVolt"));
luaVM.RegisterFunction("SetAcCurrent", this, this.GetType().GetMethod("SetAcCurrent"));
luaVM.RegisterFunction("SetDcCurrent", this, this.GetType().GetMethod("SetDcCurrent"));
luaVM.RegisterFunction("MeterValue", this, this.GetType().GetMethod("MeterValue"));
luaVM.DoFile(luaFile);
luaVM.Close();
}
catch (Exception)
{
}
finally
{
/*
this.Invoke(new MethodInvoker(delegate
{
this.buttonLuaRun.Text = "运行脚本";
}));
* */
if (this.IsHandleCreated)
{
MethodInvoker meth = new MethodInvoker(delegate
{
this.buttonLuaRun.Text = "运行脚本";
});
this.BeginInvoke(meth);
}
}
}
示例2: loadFile
//.........这里部分代码省略.........
case BindingType.PALETTE: PaletteData.TileSize = size; break;
}
}
catch (Exception)
{
MainWindow.ShowError("Plugin warning: invalid tile size provided.\nValue is ignored.");
switch (this.parentBinding.BindingType)
{
case BindingType.GRAPHICS: GraphicsData.TileSize = oldSize; break;
case BindingType.PALETTE: PaletteData.TileSize = oldSize; break;
}
}
}
#endregion
#region tiled
if (interp["tiled"] != null)
{
bool tl;
switch (this.parentBinding.BindingType)
{
case BindingType.GRAPHICS:
tl = GraphicsData.Tiled;
try { GraphicsData.Tiled = (bool)interp["tiled"]; }
catch (Exception)
{
MainWindow.ShowError("Plugin warning: invalid tile size provided.\nValue is ignored.");
GraphicsData.Tiled = tl;
}
break;
case BindingType.PALETTE:
tl = PaletteData.Tiled;
try { PaletteData.Tiled = (bool)interp["tiled"]; }
catch (Exception)
{
MainWindow.ShowError("Plugin warning: invalid tile size provided.\nValue is ignored.");
PaletteData.Tiled = tl;
}
break;
default: throw new Exception(string.Format("Unknown BindingType {0:s}", this.parentBinding.BindingType.ToString()));
}
}
#endregion
if (this.Parent.BindingType == BindingType.GRAPHICS)
{
#region width
if (interp["width"] != null)
{
uint origW = GraphicsData.Width;
try
{
uint w = (uint)(double)interp["width"];
GraphicsData.Width = w;
}
catch (Exception)
{
GraphicsData.Width = origW;
MainWindow.ShowError("Plugin warning: invalid width.\n"
+ "Value " + interp.GetString("width") + " is ignored.");
}
}
#endregion
#region height
if (interp["height"] != null)
{
uint origH = GraphicsData.Height;
try
{
uint h = (uint)(double)interp["height"];
GraphicsData.Height = h;
}
catch (Exception)
{
GraphicsData.Height = origH;
MainWindow.ShowError("Plugin warning: invalid height.\n"
+ "Value " + interp.GetString("height") + " is ignored.");
}
}
#endregion
}
if (!usedSetData)
this.bData.Data = this.theData;
if (interp["warning"] != null)
MainWindow.ShowWarning(interp.GetString("warning"));
}
}
catch (Exception e)
{
MainWindow.ShowError("Plugin error: \n" + e.Message);
}
// close and delete the interpreter, and delete the data
interp.Close();
interp = null;
this.theData = null;
}
示例3: canCompile
/// <summary>
/// Does simple syntax checking of a LUA plugin. NOTE: Doe not find runtime errors!
/// </summary>
/// <param name="code">Code to compile</param>
/// <param name="suppressExceptions">Set to false if you would like to see
/// the exception thrown, good for debugging</param>
/// <returns>True if compiling to bytecode is successful</returns>
public static Boolean canCompile(String code, Boolean suppressExceptions = true)
{
Lua tempLua = null;
try
{
tempLua = new Lua();
tempLua.LoadString(code, "CompileCheck");
}
catch (Exception ex)
{
if (suppressExceptions)
return false;
else
throw ex;
}
finally
{
if (tempLua != null)
tempLua.Close();
}
return true;
}
示例4: RunLua
private void RunLua(object obj)
{
try
{
string luaFile = obj as string;
Lua luaVM = new Lua();
luaVM.RegisterFunction("FMSignal", this, this.GetType().GetMethod("FMSignal"));
luaVM.RegisterFunction("Single", this, this.GetType().GetMethod("Single"));
luaVM.RegisterFunction("Output", this, this.GetType().GetMethod("Output"));
luaVM.RegisterFunction("OutputLine", this, this.GetType().GetMethod("OutputLine"));
luaVM.RegisterFunction("Sleep", this, this.GetType().GetMethod("Sleep"));
luaVM.DoFile(luaFile);
luaVM.Close();
}
catch (Exception)
{
}
finally
{
this.Invoke(new MethodInvoker(delegate
{
this.lua_button.Text = "运行脚本";
}));
}
}