View Single Post
03-04-13, 09:52 PM   #10
Xinhuan
A Chromatic Dragonspawn
 
Xinhuan's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 174
Originally Posted by Clamsoda View Post
Well, perhaps I should delve a bit deeper into what I am striving for. Let us say that I have an input that may have ANY value. I want to check this against a table of any possible value that may be considered valid. Let me set up a few examples:

local input = "Haleth"

local table = {
"Phanx",
"Clamsoda",
"Seerah",
"Dridzt",
"Haleth"
}

What I would like to do is construct an IF statement that if the input is ever ANY value that is in said table, that we may proceed with the code. And this process will remain true for any amount of values I add to, or remove from the table, and is independent of the input value. The input may become "apple", or "seven", in which case it wouldn't match, unless "apple" or "seven" was added to the table. Additionally, if I removed "Haleth" from the table the input would no longer be true.

I am very sorry if I missed your point, or not illustrating mine correctly.
You could restructure your table to:

local table = {
"Phanx" = 1,
"Clamsoda" = 1,
"Seerah" = 1,
"Dridzt" = 1,
"Haleth" = 1
}

If you add Phanx to the table, you would do
table["Phanx"] = (table["Phanx"] or 0) + 1

Checking if it exists is just

if (table["Phanx"]) then ...

The key is the string, and the value is the number of times it is added to the table. This method would obviously not work if you need the table to be sorted in a particular order instead.
__________________
Author of Postal, Omen3, GemHelper, BankItems, WoWEquip, GatherMate, GatherMate2, Routes and Cartographer_Routes
  Reply With Quote