本文整理汇总了C#中ILuaState.GetGlobal方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.GetGlobal方法的具体用法?C# ILuaState.GetGlobal怎么用?C# ILuaState.GetGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.GetGlobal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: B_Print
public static int B_Print( ILuaState lua )
{
StringBuilder sb = new StringBuilder();
int n = lua.GetTop();
lua.GetGlobal( "tostring" );
for( int i=1; i<=n; ++i )
{
lua.PushValue( -1 );
lua.PushValue( i );
lua.Call( 1, 1 );
string s = lua.ToString( -1 );
if( s == null )
return lua.L_Error("'tostring' must return a string to 'print'");
if( i > 1 )
sb.Append( "\t" );
sb.Append( s );
lua.Pop( 1 );
}
Debug.Log( sb.ToString() );
return 0;
}
示例2: SerializeTable
/// <summary>
/// 将Table序列化成为字符串写入文件
/// </summary>
public string SerializeTable(ILuaState _fileLua, int index)
{
//获取LibCore中_SerializeTable函数,然后串行化table, 以后要重写,从而不依赖LibCore(因为有在非运行状态下获取内容)
if (_fileLua.Type(index) != LuaType.LUA_TTABLE)
{
Debug.LogWarning("LuaExport:SerializeTable param must a table.. please check");
return "";
}
int dwStackIndex = _fileLua.GetTop();
_fileLua.PushValue(index);
_fileLua.GetGlobal("_SerializeTable");
_fileLua.Insert(-2);
_fileLua.PushBoolean(false);
if (_fileLua.PCall(2, 1, 0) != 0)
{
Debug.LogWarning(_fileLua.ToString(-1) + " in SerializeTable");
_fileLua.Pop(-1);
return "";
}
string szResult = _fileLua.ToString(-1);
//Debug.Log(m_szResult);
_fileLua.Pop(1);
if (dwStackIndex != _fileLua.GetTop())
Debug.LogWarning("LuaExport:SerializeTable stack Exception:start=" + dwStackIndex + " end=" + _fileLua.GetTop());
return szResult;
}
示例3: pushargs
/*
** Push on the stack the contents of table 'arg' from 1 to #arg
*/
static int pushargs(ILuaState L)
{
int i, n;
if (L.GetGlobal("arg") != LuaType.Table)
L.Error("'arg' is not a table");
n = L.LLen(-1);
L.CheckStack(n + 3, "too many arguments to script");
for (i = 1; i <= n; i++)
L.RawGetI(-i, i);
L.Remove(-i); /* remove table from the stack */
return n;
}
示例4: l_print
/*
** Prints (calling the Lua 'print' function) any values on the stack
*/
static void l_print(ILuaState L)
{
int n = L.GetTop();
if (n > 0)
{ /* any result to be printed? */
L.CheckStack(L.MinStack, "too many results to print");
L.GetGlobal("print");
L.Insert(1);
if (L.PCall(n, 0, 0) != LuaStatus.OK)
l_message(L, progname, L.PushFString("error calling 'print' (%s)", L.ToString(-1)));
}
}
示例5: get_prompt
/*
** Returns the string to be used as a prompt by the interpreter.
*/
static String get_prompt(ILuaState L, bool firstline)
{
string p;
L.GetGlobal(firstline ? "_PROMPT" : "_PROMPT2");
p = L.ToString(-1);
if (p == null) p = (firstline ? LUA_PROMPT : LUA_PROMPT2);
return p;
}
示例6: dolibrary
/*
** Calls 'require(name)' and stores the result in a global variable
** with the given name.
*/
static LuaStatus dolibrary(ILuaState L, String name)
{
LuaStatus status;
L.GetGlobal("require");
L.PushString(name);
status = docall(L, 1, 1); /* call 'require(name)' */
if (status == LuaStatus.OK)
L.SetGlobal(name); /* global[name] = require return */
return report(L, status);
}