本文整理汇总了C#中ILuaState.SetGlobal方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.SetGlobal方法的具体用法?C# ILuaState.SetGlobal怎么用?C# ILuaState.SetGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.SetGlobal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenLib
public static int OpenLib( ILuaState lua )
{
NameFuncPair[] define = new NameFuncPair[]
{
new NameFuncPair( "concat", TBL_Concat ),
new NameFuncPair( "maxn", TBL_MaxN ),
new NameFuncPair( "insert", TBL_Insert ),
new NameFuncPair( "pack", TBL_Pack ),
new NameFuncPair( "unpack", TBL_Unpack ),
new NameFuncPair( "remove", TBL_Remove ),
new NameFuncPair( "sort", TBL_Sort ),
};
lua.L_NewLib( define );
#if LUA_COMPAT_UNPACK
// _G.unpack = table.unpack
lua.GetField( -1, "unpack" );
lua.SetGlobal( "unpack" );
#endif
return 1;
}
示例2: 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);
}
示例3: createargtable
/// <summary>
/// Create the 'arg' table, which stores all arguments from the
/// command line ('argv'). It should be aligned so that, at index 0,
/// it has 'argv[script]', which is the script name. The arguments
/// to the script (everything after 'script') go to positive indices;
/// other arguments (before the script name) go to negative indices.
/// If there is no script name, assume interpreter's name as base.
/// </summary>
static void createargtable(ILuaState L, String[] argv, int argc, int script)
{
int i, narg;
if (script == argc) script = 0; /* no script name? */
narg = argc - (script + 1); /* number of positive indices */
L.CreateTable(narg, script + 1);
for (i = 0; i < argc; i++)
{
L.PushString(argv[i]);
L.RawSetI(-2, i - script);
}
L.SetGlobal("arg");
}