table help - Printable Version +- MMOMinion (https://www.mmominion.com) +-- Forum: FFXIVMinion (https://www.mmominion.com/forumdisplay.php?fid=87) +--- Forum: [DOWNLOADS] Addons, Lua Modules, Navigation Meshes.. (https://www.mmominion.com/forumdisplay.php?fid=90) +---- Forum: I Need Help with LUA coding! (https://www.mmominion.com/forumdisplay.php?fid=104) +---- Thread: table help (/showthread.php?tid=4620) |
table help - TauTau - 10-30-2013 I need some help with the use of tables. I'm looking for a way to check if a value is in a table, and thought maybe there is a way without looping through the table? What I want to do is this (probably syntactically wrong): Code: function Summon.ClassCanSummon() so I build a table of jobs that can summon, and want to check if the players class is in that table, and then return a true/false. Edit: I solved it by not using a table, isn't worth it for two values, I guess ;) RE: table help - z0mg - 10-30-2013 You could have done this so much simpler... For example (first reply): http://stackoverflow.com/questions/2282444/how-to-check-if-a-table-contains-an-element-in-lua SummonerClasses[FFXIV.JOBS.SUMMONER] = true SummonerClasses[FFXIV.JOBS.ARCANIST] = true if (SummonerClasses[myClass] ~= nil) then (summoner/arcanist)... else (the rest) ... RE: table help - TauTau - 10-30-2013 nice... I'm still trying to get along with LUA ;) I used this now: if (Player.job == FFXIV.JOBS.SUMMONER or Player.job == FFXIV.JOBS.ARCANIST) then return true end RE: table help - z0mg - 10-30-2013 Even then, do yourself a favor and do return Player.job == X or Player.job == y, saves a whole line! :D RE: table help - KaWeNGoD - 10-30-2013 Code: function Summon.ClassCanSummon() or Code: function Summon.ClassCanSummon() RE: table help - TauTau - 10-30-2013 (10-30-2013, 02:57 PM)KaWeNGoD Wrote: from what I've read here https://github.com/MMOMinion/FFXIVMinion/wiki/Enumerations it is recommended to use the Enumerations (since the result could change with a patch) |