So, first, I STRONGLY recommend you take the time to use proper tab-indenting in your code. Your code above has two extra end statements that were very hard to spot because things weren't properly lined up. I'm going to guess that the reason you added them is due to some thought that you need a separate end statement for an else statement, in addition to the one for the if statement, which isn't the case.
Second, you created a table called imageA, then you added an argument to the Istyle function called imageA, which means that for the purposes of that function, your table is overwritten with the first argument you give to the function, which is undoubtedly NOT what you want. You need to remove the argument from your function declaration, at which point the table will be useable.
Third, you have a pair of if statements that, combined, mean your function will never send any commands. Specifically, you first have "if is_far then", which in its else statement prints an error message and returns, followed by "if not is_far then", which does the exact same thing in its else statement. But it is always the case that one of those two things is true, and the else case of each of those if statements is the if case of the other.
Fourth, do you a whole thing with "abilityI"... but never declare it, receive it as an argument, or do anything with it afterward. This is clearly a problem.
Fifth, it seems as if you are trying to include some values from the table into the command you are going to send... only you never do that. The lines where you are concatenating things together to make the command you will send are using " " (the value of cmt at the time) rather than anything pulled from the table.
Here is your code with a number of comments added, the tabs done properly, and your two extra end statements commented out.
local imageA = {p = "Pierce", b = "Bleed", c = "Crush", sh = "shroud", ds = "dullsense", nb = "Nimbus",
lo = "Look", rx = "Relaxation", hm = "Human", bu = "Burn", tc = "truecripple", tw = "twist",
db = "dumb", pr = "protection", md = "meld", wr = "whirl", rv = "revive", fp = "fop"}
function Istyle(imageA, cStyle)
cStyle = cStyle -- cStyle already equals itself... what is this doing?
local is_far = cStyle:find("p") -- since this is all cStyle is used for, is cStyle just equal to "p" when used?
-- if so, just use cStyle == "p", rather than cStyle:find("p")
local cmt = "" -- this starts out as "", but then is made into " " just a few lines down... why not start as " "?
display(imageA)
display(cStyle)
-- where does abilityI come from?
if table_contains(imageA, abilityI) then -- you don't seem to do anything with this
abilityI = imageA[abilityI]
cmt = " " -- see comment below
else
cmt = " " -- if both cases do the same thing, there is no need to put this inside the if statement
end
-- end -- commented out because this would have become the end of the function
-- you seem to be trying to use some value from the table above in cmt here, but that is never set
if is_far then
cmt = "image " .. cmt
else -- == if not is_far then
print("Not Found")
return
end
if not is_far then -- this case will never happen
cmt = "unwield right;wield " .. lastwax " right;image " .. cmt .. ";unwield right"
else -- == if is_far then -- if it makes it this far, this case will always happen
print("Not Found")
return
end
send(cmt) -- you can't get here, ever, because of the return statements in your else cases
end
-- end -- commented out because you have a dangling end statement