本文整理汇总了C#中SharpLua.LuaTypes.LuaTable.GetKey方法的典型用法代码示例。如果您正苦于以下问题:C# LuaTable.GetKey方法的具体用法?C# LuaTable.GetKey怎么用?C# LuaTable.GetKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpLua.LuaTypes.LuaTable
的用法示例。
在下文中一共展示了LuaTable.GetKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: REPL
//.........这里部分代码省略.........
#else
GlobalEnvironment.SetNameValue("DEBUG", LuaBoolean.False);
#endif
Prompt = "> ";
// load startup scripts
LoadFiles();
// check command line args
if (args.Length > 0)
{
string file = args[0];
if (File.Exists(file))
{
try
{
GlobalEnvironment.SetNameValue("_WORKDIR", new LuaString(Path.GetDirectoryName(file)));
if (file.EndsWith(".out") || file.EndsWith(".luac") || file.EndsWith(".sluac"))
{
Chunk c = Serializer.Deserialize(file) as Chunk;
c.Enviroment = GlobalEnvironment;
bool isBreak;
c.Execute(GlobalEnvironment, out isBreak).ToString();
}
else
{
LuaRuntime.RunFile(file, GlobalEnvironment);
}
// it loaded successfully
if (args.Length > 1) // possibly interactive mode after
Console.WriteLine("Loaded file '" + Path.GetFileName(file) + "'");
}
catch (Exception error)
{
Console.WriteLine(error.Message);
}
//Console.ReadKey(true);
//return;
// instead, go to interactive
}
else
{
Console.WriteLine(file + " not found.");
}
}
// check for interactive mode
foreach (string arg in args)
if (arg.ToUpper() == "-I")
GoInteractive = true;
if (args.Length == 0)
GoInteractive = true;
if (GoInteractive)
{
while (true)
{
Console.Write(Prompt);
string line = Console.ReadLine();
if (line == "quit" || line == "exit" || line == "bye")
{
break;
}
else
{
try
{
LuaValue v = Run(line, GlobalEnvironment);
if (v == null)
Console.WriteLine("=> [no returned value]");
else
Console.WriteLine("=> " + v.ToString());
}
catch (Parser.ParserException error)
{
// create spacing
StringBuilder sb = new StringBuilder();
for (int i = 0; i < Prompt.Length; i++)
sb.Append(" ");
for (int i = 0; i < error.FirstErrorIndex; i++)
sb.Append(" ");
Console.WriteLine(sb.ToString() + "^");
Console.WriteLine("Error: " + error.Message);
GlobalEnvironment.SetNameValue("LASTERROR", ObjectToLua.ToLuaValue(error));
}
catch (Exception error)
{
if (((LuaBoolean)GlobalEnvironment.GetValue(GlobalEnvironment.GetKey("DEBUG"))) == LuaBoolean.True)
Console.WriteLine(error.ToString());
else
Console.WriteLine("Error: " + error.Message);
GlobalEnvironment.SetNameValue("LASTERROR", ObjectToLua.ToLuaValue(error));
}
}
}
}
}