WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   nil returning functions (https://www.wowinterface.com/forums/showthread.php?t=57268)

Aeriez 07-07-19 12:15 PM

nil returning functions
 
So I'm probably brain farting after years of not programming. But this seems like it's relatively unique to Lua. When checking a function for a value/true vs nil/false, is there a shorthand to prevent it from throwing Lua errors? Below is an example and not so much broken code:

Lua Code:
  1. if IsInParty() then
  2.     NumGroup = GetNumPartyMembers()
  3.     GroupType = "party"
  4. elseif IsInRaid() then
  5.     NumGroup = GetNumRaidMembers()
  6.     GroupType = "raid"
  7. end

It always throws "attempt to call global 'IsInParty' (a nil value)" and stops the entire program. Ya, no kidding it's nil... that's literally what I'm checking for. Any insight would be great because this has been plaguing me lol.

Edit: Irony to note, this is almost identical to the example in the wiki for IsInParty or IsInRaid. So i'm assuming it's relatively new for them to disallow nil returns in functions literally intended to return nil most of the time.

Fizzlemizz 07-07-19 12:28 PM

Maybe IsInGroup ;). The error is saying "IsInParty" doesn't exists, not the return.

Aeriez 07-07-19 12:42 PM

Ok so my problem was just a brain fart. Figures. Thanks! They've gone through too many different variants of those functions.


All times are GMT -6. The time now is 10:15 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI