Issue with select() and IsInInstance()
Is there a reason why:
Lua Code:
returns BOOLEAN, TYPE and Lua Code:
returns BOOLEAN TYPE together? Select(2, *) returns JUST the type, so why can't I return just the boolean? |
Because select returns all values after the one specified, as well.
If you just want the first value, just do "local inInstance = IsInInstance()". There is a way to force it to only return one value, and that's by wrapping it in parentheses, but there's no reason to do that here. |
Nevermind, thank you.
Zzzzz -.- |
Quote:
|
Normal lua behavior, use (IsInInstance()) to only get the first.
|
Quote:
|
You need to wrap your function in parenthesis like so:
print((select(2, GetWorldStateUIInfo(3)))) If that doesn't work, try: local _, state = GetWorldStateUIInfo(3) Edit: Fixed a mistake. |
Quote:
|
Quote:
Quote:
(The post by Clamsoda put them around the wrong function.) Code:
print((select(2, GetWorldStateUIInfo(3)))) |
Quote:
"tostring(select(2, GetWorldStateUIInfo(3)))" |
Quote:
|
Yes. You need to wrap select() in its own parenthisis, THEN wrap that in tostring() -- or whatever function you are calling -- if you want to JUST return the 2nd argument of GetWorldStateUIInfo().
Code:
tostring( ( select(2, GetWorldStateUIInfo(3)) ) ) There really is no downside to using the "local _, state = GetWorldStateUIInfo(3)" approach, especially when you are only one argument deep into the function. It is faster, and you can just make "_" local in your file if your are worried about global leaks (though that was fixed). |
Quote:
|
Quote:
|
Calling the select() function is extremely slow. Besides, you are just recycling "_" over and over. It is one variable, there isn't much overhead associated with that.
|
Select or not to select
So i shouldn't use select on "COMBAT_LOG_EVENT_UNFILTERED"?
|
oooh :( no.
|
On a related note, I saw this in an AddOn I downloaded a while back:
Code:
local var1, var2 = select(1, ...) Code:
local var1, var2 = ... |
Yes. No offense to whomever's addon that was, but doing that is just dumb. ;)
|
Quote:
|
All times are GMT -6. The time now is 01:53 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI