本文整理汇总了C#中ILuaState.PushFString方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.PushFString方法的具体用法?C# ILuaState.PushFString怎么用?C# ILuaState.PushFString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.PushFString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: msghandler
/*
** Message handler used to run all chunks
*/
static int msghandler(ILuaState L)
{
String msg = L.ToString(1);
if (msg == null)
{ /* is error object not a string? */
if (L.CallMeta(1, "__tostring") /*!= 0*/ && /* does it have a metamethod */
L.Type(-1) == LuaType.String) /* that produces a string? */
return 1; /* that is the message */
else
msg = L.PushFString("(error object is a %s value)", L.TypeName(1));
}
L.Traceback(L, msg, 1); /* append a standard traceback */
return 1; /* return the traceback */
}
示例2: pushline
/*
** Prompt the user, read a line, and push it into the Lua stack.
*/
static int pushline(ILuaState L, bool firstline)
{
//char[] buffer = new Char[LUA_MAXINPUT];
//char *b = buffer;
string b;
int l;
string prmt = get_prompt(L, firstline);
bool readstatus = lua_readline(L, out b, prmt);
if (!readstatus)
return 0; /* no input (prompt will be popped by caller) */
L.Pop(1); /* remove prompt */
l = b.Length;
//if (l > 0 && b[l-1] == '\n') /* line ends with newline? */
// b[--l] = '\0'; /* remove it */
if (firstline && b.StartsWith("=")) /* for compatibility with 5.2, ... */
L.PushFString("return %s", b.Substring(1)); /* change '=' to 'return' */
else
L.PushLString(b, l);
lua_freeline(L, b);
return 1;
}
示例3: 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)));
}
}