本文整理汇总了C#中LuaInterface.LuaTable.push方法的典型用法代码示例。如果您正苦于以下问题:C# LuaTable.push方法的具体用法?C# LuaTable.push怎么用?C# LuaTable.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaInterface.LuaTable
的用法示例。
在下文中一共展示了LuaTable.push方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resume
public int Resume(object[] args, LuaTable env)
{
int result = 0;
int oldTop = LuaDLL.lua_gettop(L);
// If thread isn't started, it needs to be restarted
if( start )
{
start = false;
func.push( L );
if (env != null)
{
env.push(L);
LuaDLL.lua_setfenv(L, -2);
}
result = resume(args, oldTop);
}
// If thread is suspended, resume it
else if( IsSuspended() )
{
result = resume(args, oldTop);
}
return result;
}
示例2: DoFile
/*
* Excutes a Lua file and returns all the chunk's return
* values in an array
*/
public object[] DoFile(string fileName, LuaTable env)
{
LuaDLL.lua_pushstdcallcfunction(L,tracebackFunction);
int oldTop=LuaDLL.lua_gettop(L);
// Load with Unity3D resources
byte[] text = LuaStatic.Load(fileName);
if (text == null)
{
ThrowExceptionFromError(oldTop);
}
//Encoding.UTF8.GetByteCount(text)
if (LuaDLL.luaL_loadbuffer(L, text, text.Length, fileName) == 0)
{
if (env != null)
{
env.push(L);
//LuaDLL.lua_setfenv(L, -1);
LuaDLL.lua_setfenv(L, -2);
}
if (LuaDLL.lua_pcall(L, 0, -1, -2) == 0)
{
object[] results = translator.popValues(L, oldTop);
LuaDLL.lua_pop(L, 1);
return results;
}
else
{
ThrowExceptionFromError(oldTop);
}
}
else
{
ThrowExceptionFromError(oldTop);
}
return null; // Never reached - keeps compiler happy
}
示例3: DoString
/// <summary>
/// Executes a Lua chnk and returns all the chunk's return values in an array.
/// </summary>
/// <param name="chunk">Chunk to execute</param>
/// <param name="chunkName">Name to associate with the chunk</param>
/// <returns></returns>
public object[] DoString(string chunk, string chunkName, LuaTable env)
{
int oldTop = LuaDLL.lua_gettop(L);
byte[] bt = Encoding.UTF8.GetBytes(chunk);
if (LuaDLL.luaL_loadbuffer(L, bt, bt.Length, chunkName) == 0)
{
if (env != null)
{
env.push(L);
//LuaDLL.lua_setfenv(L, -1);
LuaDLL.lua_setfenv(L, -2);
}
if (LuaDLL.lua_pcall(L, 0, -1, 0) == 0)
return translator.popValues(L, oldTop);
else
ThrowExceptionFromError(oldTop);
}
else
ThrowExceptionFromError(oldTop);
return null; // Never reached - keeps compiler happy
}
示例4: LoadString
/// <summary>
///
/// </summary>
/// <param name="chunk"></param>
/// <param name="name"></param>
/// <returns></returns>
public LuaFunction LoadString(string chunk, string name, LuaTable env)
{
int oldTop = LuaDLL.lua_gettop(L);
byte[] bt = Encoding.UTF8.GetBytes(chunk);
if (LuaDLL.luaL_loadbuffer(L, bt, bt.Length, name) != 0)
ThrowExceptionFromError(oldTop);
if (env != null)
{
env.push(L);
LuaDLL.lua_setfenv(L, -2);
}
LuaFunction result = translator.getFunction(L, -1);
translator.popValues(L, oldTop);
return result;
}
示例5: SetMetaTable
public void SetMetaTable(LuaTable metaTable)
{
push(_Interpreter.L);
metaTable.push(_Interpreter.L);
LuaDLL.lua_setmetatable(_Interpreter.L, -2);
LuaDLL.lua_pop(_Interpreter.L, 1);
}
示例6: DoString
/// <summary>
/// Executes a Lua chnk and returns all the chunk's return values in an array.
/// </summary>
/// <param name="chunk">Chunk to execute</param>
/// <param name="chunkName">Name to associate with the chunk</param>
/// <returns></returns>
public object[] DoString(string chunk, string chunkName, LuaTable env)
{
//Returns the index of the top element in the stack. Because indices start at 1,
//this result is equal to the number of elements in the stack;
//in particular, 0 means an empty stack.
int oldTop = LuaDLL.lua_gettop(L);
byte[] bt = Encoding.UTF8.GetBytes(chunk);
//Loads a Lua chunk without running it.
//If there are no errors, lua_load pushes the compiled chunk as a Lua function on top of the stack.
//Otherwise, it pushes an error message.
if (LuaDLL.luaL_loadbuffer(L, bt, bt.Length, chunkName) == 0)
{
if (env != null)
{
env.push(L);
//LuaDLL.lua_setfenv(L, -1);
LuaDLL.lua_setfenv(L, -2);
}
//However, if there is any error, lua_pcall catches it, pushes a single value on the stack (the error message),and returns an error code.
//Like lua_call, lua_pcall always removes the function and its arguments from the stack.
if (LuaDLL.lua_pcall(L, 0, -1, 0) == 0)
//Revert to the state before call trunk
return translator.popValues(L, oldTop);
else
ThrowExceptionFromError(oldTop);
}
else
ThrowExceptionFromError(oldTop);
return null; // Never reached - keeps compiler happy
}