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_pcall removes 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)
|
请发表评论