function returning multiple strings
I'm using the GetGuildMemberInfo() function and it returns multiple strings:
Returns: string name, string note, integer rankIndex, integer playerStatus, integer secsSinceLogoff I can't figure out how to access individual strings because it doesn't seem like these are returned in an array. local xx = GetGuildMemberInfo(1 ,1) d(xx[1]) -- should return the guild members name, but it's not an array... |
Lua Code:
|
Welcome to lua. :D Ayantir showed how to catch them. Note the local is important to avoid Global leaking. Say you don't care about the fourth return. Then this can be done.
Lua Code:
Lua Code:
You could try 'unpack' the returns just to the debug message. It should be work since it is string and integers. Lua Code:
|
Thanks guys, fixed my issue perfectly. I was wondering what the underscore business was about too.
|
Quote:
You can turn it into an array with: Lua Code:
Unpack is to go the other way if you need to get from an array to list of values: Lua Code:
See http://www.lua.org/pil/5.1.html for more details about multiple return values and unpack. |
All times are GMT -6. The time now is 11:32 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI