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.