You call lua_pcall with the number of arguments you are passing and the number of results you want. The fourth argument indicates an error-handling function; we will discuss it in a moment. As in a Lua assignment, lua_pcall adjusts the actual number of results to what you have asked for, pushing nils or discarding extra values as needed. Before pushing the results, lua_pcallremoves from the stack the function and its arguments. If a function returns multiple results, the first result is pushed first; so, if there are n results, the first one will be at index -n and the last at index -1.

意思就是:当一个函数有多个返回值,第一个返回值首先push,第二个返回值再push,以此类推。

所以要想得到第一个返回值就:lua_toxxxx(L,1),第二个返回值就是lua_toxxxxx(L,2)

LUA pcall 多个返回值的更多相关文章

  1. lua调用c++函数返回值作用

    2015/05/28 lua调用c++接口,返回给lua函数的是压入栈的内容,可以有多个返回值.但是c++接口本身也是有返回值的,这个返回值也非常的重要,会决定最后返回到lua函数的值的个数. (1) ...

  2. C++获取Lua全局变量和执行Lua多参数多返回值函数

    C++代码: // LuaAndC.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #i ...

  3. Lua 中string.gsub(sourceString, pattern, replacementString) 返回值有两个

    这阵子在学习lua,今天看到string操作,书中描述string.gsub(sourceString, pattern, replacementString)返回一个字符串,但是我在实际操作中却发现 ...

  4. <5>Lua多返回值和require模块

    1.多返回值 --1: 一个lua函数可以返回多个返回值: --2: 定义多个变量来接受多返回值 --3: lua的unpack函数,解开表里的单个的值; 结果 2.require模块 --1: 第一 ...

  5. lua入门之二:c/c++ 调用lua及多个函数返回值的获取

    当 Lua 调用 C 函数的时候,使用和 C 调用 Lua 同样类型的栈来交互. C 函数从栈中获取她的參数.调用结束后将返回结果放到栈中.为了区分返回结果和栈中的其它的值,每一个 C 函数还会返回结 ...

  6. Lua中返回值的丢失问题

    Lua中返回值的丢失问题 -- 如果函数调用所得的多个返回值是另外一个函数的最后一个参数,或者是多指派表达式中的最后一个参数时,所有返回值将被传入或使用. -- 否则只有第一个返回值被使用或指定. T ...

  7. lua 基础 2 类型和值

    -- 类型 和 值--[[ 8中类型 滚动类nil.boolean. number.string.userdata.function.thread 和 table.]] print (type(&qu ...

  8. Lua中的类型与值

    [基础介绍] Lua是一种动态类型的语言.在语言中没有类型定义的语法,每个值都带有其自身的类型信息.在Lua中有8中基本类型,分别是: nil(空)类型 boolean(布尔)类型 number(数字 ...

  9. Lua学习之类型与值

    Lua是一种动态语言,在语言中没有类型定义的语法. 在lua中有8中基本的类型: 1.nil(空) 2.boolean 3.number(数字) 4.string(字符串) 5.userdata(自定 ...

随机推荐

  1. 让Windows加入域的PowerShell

    $domain = "midrange.lab" $password = "MyPassword!" | ConvertTo-SecureString -asP ...

  2. Linux下安装nmap扫描工具

    NMAP是一款流行的网络扫描和嗅探工具,被广泛应用在黑客领域做漏洞探测以及安全扫描,更多的nmap是一个好用的网络工具,在生产和开发中也经常用到,主要做端口开放性检测和局域网信息的查看收集等,不同Li ...

  3. JAVA-jar包下载地址

    spring mvc常用jar包 commons-logging:http://commons.apache.org/proper/commons-logging/download_logging.c ...

  4. Spring(十):Spring配置Bean(三)Bean的作用域、使用外部属性文件

    Bean的作用域: 支持四种配置,分别是singleton,prototype,request,session. singleton 默认情况下在spring confinguration xml文件 ...

  5. guava 学习笔记 瓜娃(guava)的API快速熟悉使用

    1,大纲 让我们来熟悉瓜娃,并体验下它的一些API,分成如下几个部分: Introduction Guava Collection API Guava Basic Utilities IO API C ...

  6. Android中创建option menu

    1.首先在res目录下新建一个menu文件夹,右击res目录->New->Directory,输入文件夹名menu,点击OK. 接着在这个文件夹下再新建一个名叫main的菜单文件,右击me ...

  7. HtmlAgilityPack 详细使用

    使用HtmlAgilityPack抓取网页数据 http://www.cnblogs.com/yxlblogs/p/3499420.html http://www.cnblogs.com/xdpxyx ...

  8. 简单实用的extend对象合并

    /** * 合并对象 * 示例:o = extend({ a: 'a' }, o); */ function extend(s, t) { if (!s) { return {}; } if (!s) ...

  9. LintCode: Combination Sum

    一个数可以使用多次 图: 节点:x(当前的和,当前要考虑的数a[i]) 边:x-> y1(当前的和,下一个要考虑的数a[i+1]) y2(当前的和+a[i],下一个要考虑的数a[i+1]) BF ...

  10. Microsoft® SQL Server® 2008 Express with Tools

    https://www.microsoft.com/zh-cn/download/confirmation.aspx?id=22973