If you read the error message it is telling you that key1 happened to have been a string value and not a number. And the line is trying to use it in an arithmetic formula. Bad juju.
Your best bet to identify why that is, is to use the print(type(key1),key1) command just before that line to see what it is currently holding. If it shows a value you were expecting but still not working I think the function is tonumber which converts a string formatted number into an actual number. That might then solve your problem for that line.
|