本文整理汇总了C#中LuaState.NewTable方法的典型用法代码示例。如果您正苦于以下问题:C# LuaState.NewTable方法的具体用法?C# LuaState.NewTable怎么用?C# LuaState.NewTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaState
的用法示例。
在下文中一共展示了LuaState.NewTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetSetUserValue
public void TestGetSetUserValue()
{
LuaState L = null;
using (L = new LuaState())
{
L.NewTable();
Assert.Equal(15, (int)L.GetUserValue(1));
L.PushString("UserValue");
L.SetUserValue(1);
Assert.Equal(2, L.GetTop());
Assert.Equal(LuaType.String, L.GetUserValue(1));
L.SetTop(0);
var ud = L.NewUserData(12);
Assert.Equal(LuaType.Nil, L.GetUserValue(1));
L.PushString("UserValue");
L.SetUserValue(1);
Assert.Equal(2, L.GetTop());
Assert.Equal(LuaType.String, L.GetUserValue(1));
}
}
示例2: TestNext
public void TestNext()
{
LuaState L = null;
using (L = new LuaState())
{
L.NewTable();
var t = L.GetTop();
L.PushString("Value A");
L.SetField(t, "a");
L.PushString("Value 2");
L.SetI(t, 2);
Assert.Equal(1, L.GetTop());
int count = 0;
bool foundA = false;
// First Key
L.PushNil();
while (L.Next(t))
{
count++;
// => 'key' at index -2 , 'value' as index -1
if (LuaType.String == L.Type(-2))
{
Assert.False(foundA);
Assert.Equal(LuaType.String, L.Type(-2));
Assert.Equal("a", L.ToString(-2));
Assert.Equal(LuaType.String, L.Type(-1));
Assert.Equal("Value A", L.ToString(-1));
foundA = true;
}
else
{
// Second key
Assert.Equal(LuaType.Number, L.Type(-2));
Assert.Equal(2, L.ToInteger(-2));
Assert.Equal(LuaType.String, L.Type(-1));
Assert.Equal("Value 2", L.ToString(-1));
}
// Remove 'value' and keep the 'key' on the stack for the next key
L.Pop(1);
}
Assert.Equal(2, count);
Assert.True(foundA);
// No more key
// The stack is cleaned
Assert.Equal(1, L.GetTop());
}
}
示例3: TestGetSetMetatable
public void TestGetSetMetatable()
{
LuaState L = null;
using (L = new LuaState())
{
// Create the working table
L.NewTable();
// Get the metatable
Assert.False(L.GetMetatable(1));
// Create and set the metatable
L.NewTable();
L.SetMetatable(1);
// Get the metatable
Assert.True(L.GetMetatable(1));
Assert.Equal(2, L.GetTop());
}
}
示例4: TestNewTable
public void TestNewTable()
{
LuaState L = null;
using (L = new LuaState())
{
L.NewTable();
Assert.Equal(1, L.GetTop());
Assert.Equal(LuaType.Table, L.Type(-1));
}
}