Thread Tools Display Modes
08-03-13, 03:54 AM   #21
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by myrroddin View Post
I was looking for a syntactic shortcut where none exists.
Such shortcuts exist in some other languages, but not in Lua.

However, if you're checking a larger number of values, and you know ahead of time which values you're going to check against, you can clean up your code and avoid giant "if _ or _ or _ or _" chains by using a table:

Code:
local valuesToCheck = {
    baboon = true,
    cat = true,
    dog = true,
    elephant = true,
    frog = true,
}

if valuesToCheck[var] then
   -- do x
end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-03-13, 08:09 PM   #22
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
So how do I check a person's riding skill? I'm not finding much by the way of Google but an outdated GetSkillLineInfo. I need to be able to exclude mounts that a player can't use due to profession, riding skill, cloud serpent skill and the such.
  Reply With Quote
08-03-13, 09:06 PM   #23
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Riding skill is no longer an actual skill, like professions. It's just a spell that appears in your spellbook, so just use IsSpellKnown with the spell ID you are interested in.

However, there's not really any reason to do that, or to build a database of conditions (eg. this mount requires this skill in this profession) and check them all (eg. does the player have this skill in this profession?). Just use IsUsableSpell on each mount's spell ID to see if it's usable at the time before adding it to your list.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-03-13, 09:25 PM   #24
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Phanx View Post
Just use IsUsableSpell on each mount's spell ID to see if it's usable at the time before adding it to your list.
This won't work if you log in while indoors and can't mount, for example. When the table is compiled, you won't be able to use any of your mounts. (Also goes for swimming mounts like the sea horse - unless you're swimming and can *actually* use the mount, the function will return nil.)

/edit: IsUsableSpell also returns 1 instead of nil for the Flying Carpet on a character that doesn't have tailoring and can't use it.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh


Last edited by Seerah : 08-03-13 at 09:27 PM.
  Reply With Quote
08-13-13, 10:47 PM   #25
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Is it possible to create a button that you can drag onto your action bars? Right now I have a macro to run the addon but I'd rather avoid macros because some people use up all their macros already but I prefer to have something that can be either standalone or on the action bars (because I personally prefer it to be on my action bar and frankly the macro itself is good enough for me lol). If not I'll just have a button but yeah...

And I know I haven't checked back in in a while but I am still working on this... just been working on a couple things at once in the bit of time I have.
  Reply With Quote
08-14-13, 12:19 PM   #26
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
If you want something to drag onto your action bars, you need to use a macro. But you can create a button that can be placed elsewhere on the screen.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
08-14-13, 07:21 PM   #27
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Ok thank you. I'll probably just make a standalone button and when players first load give them an option to create a macro as well.
  Reply With Quote
08-14-13, 10:25 PM   #28
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Don't forget to also give them an option to hide the button -- nothing's worse than an addon that puts some useless thing on your screen (eg. the button is useless if I'm using a macro) and doesn't give you any way to hide it.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Saving values to different tables in a loop.

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