Quantcast nil returning functions - WoWInterface
Thread Tools Display Modes
07-07-19, 12:15 PM   #1
Aeriez
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
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.

Last edited by Aeriez : 07-07-19 at 12:24 PM.
  Reply With Quote
07-07-19, 12:28 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,124
Maybe IsInGroup . The error is saying "IsInParty" doesn't exists, not the return.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
07-07-19, 12:42 PM   #3
Aeriez
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
Ok so my problem was just a brain fart. Figures. Thanks! They've gone through too many different variants of those functions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » nil returning functions

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off