本文整理汇总了C#中SharpLua.LuaTypes.LuaTable.AddValue方法的典型用法代码示例。如果您正苦于以下问题:C# LuaTable.AddValue方法的具体用法?C# LuaTable.AddValue怎么用?C# LuaTable.AddValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpLua.LuaTypes.LuaTable
的用法示例。
在下文中一共展示了LuaTable.AddValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QuaternionToTable
public static LuaTable QuaternionToTable(Quaternion q)
{
LuaTable t = new LuaTable();
t.AddValue(new LuaNumber(q.x));
t.AddValue(new LuaNumber(q.y));
t.AddValue(new LuaNumber(q.z));
t.AddValue(new LuaNumber(q.w));
return t;
}
示例2: Evaluate
public override LuaValue Evaluate(LuaTable enviroment)
{
LuaTable table = new LuaTable();
foreach (Field field in this.FieldList)
{
NameValue nameValue = field as NameValue;
if (nameValue != null)
{
table.SetNameValue(nameValue.Name, nameValue.Value.Evaluate(enviroment));
continue;
}
KeyValue keyValue = field as KeyValue;
if (keyValue != null)
{
table.SetKeyValue(
keyValue.Key.Evaluate(enviroment),
keyValue.Value.Evaluate(enviroment));
continue;
}
ItemValue itemValue = field as ItemValue;
if (itemValue != null)
{
table.AddValue(itemValue.Value.Evaluate(enviroment));
continue;
}
}
return table;
}
示例3: GetParentClasses
public LuaValue GetParentClasses(LuaValue[] args)
{
LuaTable t = new LuaTable();
foreach (LuaClass p in ParentClasses)
t.AddValue(p);
return t;
}
示例4: ToLuaTable
public static LuaTable ToLuaTable(object o)
{
LuaTable ret = new LuaTable();
// check if Dictionary...
System.Collections.IDictionary dict = o as System.Collections.IDictionary;
if (dict != null)
{
foreach (object obj in dict.Keys)
{
ret.SetKeyValue(ToLuaValue(obj), ToLuaValue(dict[obj]));
}
return ret;
}
System.Collections.IEnumerable ie = (o as System.Collections.IEnumerable);
if (ie != null)
{
foreach (object obj in ie)
{
ret.AddValue(ToLuaValue(obj));
}
return ret;
}
// check if <type>...
// not an array type
ret.AddValue(ToLuaValue(o));
return ret;
}
示例5: ToLuaValue
public static LuaValue ToLuaValue(object value)
{
if ((value as LuaValue) != null)
return value as LuaValue;
if (value is int || value is double)
{
return new LuaNumber(Convert.ToDouble(value));
}
else if (value is string)
{
return new LuaString((string)value);
}
else if (value is bool)
{
return LuaBoolean.From((bool)value);
}
else if (value == null)
{
return LuaNil.Nil;
}
else if (value.GetType().IsEnum)
{
return new LuaString(value.ToString());
}
else if (value.GetType().IsArray)
{
LuaTable table = new LuaTable();
foreach (var item in (value as Array))
{
table.AddValue(ToLuaValue(item));
}
return table;
}
else if (value is LuaValue)
{
return (LuaValue)value;
}
else
{
LuaUserdata data = new LuaUserdata(value);
data.MetaTable = GetControlMetaTable();
return data;
}
}
示例6: Vector3dToTable
public static LuaTable Vector3dToTable(Vector3d v)
{
LuaTable t = new LuaTable();
t.AddValue(new LuaNumber(v.x));
t.AddValue(new LuaNumber(v.y));
t.AddValue(new LuaNumber(v.z));
return t;
}
示例7: RegisterFunctions
public static void RegisterFunctions(LuaTable module)
{
// cpath -> cspath?
module.SetNameValue("cpath", new LuaString(".\\?;.\\?.dll;.\\?.exe"));
module.SetNameValue("path", new LuaString(".\\?;.\\?.lua;.\\?.slua;.\\?.wlua;" + System.Environment.GetEnvironmentVariable("LUA_PATH")));
module.SetNameValue("bpath", new LuaString(".\\?;.\\?.luac;.\\?.out;.\\?.sluac"));
module.SetNameValue("loaded", new LuaTable());
module.SetNameValue("preload", new LuaTable());
module.Register("seeall", SeeAll);
// Load package loader functions
LuaTable loaderfunctions = new LuaTable();
loaderfunctions.Register("PreloadSearcher", new LuaFunc(delegate(LuaValue[] args) {
LuaTable t = (LuaRuntime.GlobalEnvironment.GetValue("package") as LuaTable).GetValue("preload") as LuaTable;
string mod = (args[0] as LuaString).Text;
LuaValue v = t.GetValue(mod);
if (v != null && v != LuaNil.Nil)
return new LuaMultiValue(new LuaValue[] {LuaBoolean.True, v as LuaTable});
else
return new LuaMultiValue(new LuaValue[] {LuaBoolean.False});
}));
loaderfunctions.Register("PathSearcher", new LuaFunc(delegate(LuaValue[] args)
{
// get package.path variable
string path = (LuaRuntime.GlobalEnvironment.GetValue("package") as LuaTable).GetValue("path").Value.ToString();
// split into paths
string[] paths = path.Split(';');
// check file names
foreach (string p in paths)
{
foreach (LuaValue arg in args)
{
string sfn = arg.Value.ToString();
string fn = p.Replace("?", sfn);
if (File.Exists<PackageLib>(fn))
{
LuaTable m = new LuaTable();
m.AddValue(LuaRuntime.RunFile(fn, LuaRuntime.GlobalEnvironment));
return new LuaMultiValue(new LuaValue[] { LuaBoolean.True, LuaRuntime.GlobalEnvironment.GetValue(fn) }); // Path.GetFileNameWithoutExtension(fn)
}
}
}
return new LuaMultiValue(new LuaValue[] {LuaBoolean.False});
}));
loaderfunctions.Register("CSPathSearcher", new LuaFunc(delegate(LuaValue[] args)
{
// get package.path variable
string path = (LuaRuntime.GlobalEnvironment.GetValue("package") as LuaTable).GetValue("cpath").Value.ToString();
// split into paths
string[] paths = path.Split(';');
// check file names
foreach (string p in paths)
{
foreach (LuaValue arg in args)
{
string sfn = arg.Value.ToString();
string fn = p.Replace("?", sfn);
if (File.Exists<PackageLib>(fn))
{
A8Console.WriteLine("Loading file '" + fn + "'...");
string[] modules = ExternalLibraryLoader.Load(fn);
LuaTable t = LuaRuntime.GlobalEnvironment.GetValue(modules[0]) as LuaTable;
return new LuaMultiValue(new LuaValue[] {LuaBoolean.True, t});
}
}
}
return new LuaMultiValue(new LuaValue[] {LuaBoolean.False});
}));
loaderfunctions.Register("BinarySearcher", new LuaFunc(delegate(LuaValue[] args)
{
// get package.path variable
string path = (LuaRuntime.GlobalEnvironment.GetValue("package") as LuaTable).GetValue("bpath").Value.ToString();
// split into paths
string[] paths = path.Split(';');
// check file names
foreach (string p in paths)
{
foreach (LuaValue arg in args)
{
string sfn = arg.Value.ToString();
string fn = p.Replace("?", sfn);
if (File.Exists<PackageLib>(fn))
{
LuaTable m = new LuaTable();
bool isBreak;
m.AddValue((Serializer.Deserialize(fn) as AST.Chunk).Execute(LuaRuntime.GlobalEnvironment, out isBreak));
return new LuaMultiValue(new LuaValue[] { LuaBoolean.True, LuaRuntime.GlobalEnvironment.GetValue(fn) }); // Path.GetFileNameWithoutExtension(fn)
}
}
}
return new LuaMultiValue(new LuaValue[] {LuaBoolean.False});
}));
module.SetNameValue("loaders", loaderfunctions);
module.Register("loadlib", new LuaFunc((LuaValue[] args) =>
{
return args[0];
}));
//.........这里部分代码省略.........
示例8: GetMatches
private static LuaTable GetMatches(LuaValue[] args)
{
LuaTable t = new LuaTable();
string s = (args[0] as LuaString).Text;
string format = (args[1] as LuaString).Text;
Regex re = new Regex(format);
Match m = re.Match(s);
while (m.Success)
{
for (int i = 0; i < m.Groups.Count; i++)
{
Group g = m.Groups[i];
CaptureCollection cc = g.Captures;
for (int j = 0; j < cc.Count; j++)
{
Capture c = cc[j];
t.AddValue(new LuaString(c.Value));
}
}
m = m.NextMatch();
}
return t;
}