01 | elements = { |
02 | ElemA = 1 , |
03 | ElemB = 2 , |
04 | ElemC = 3 , |
05 | Wood = 4 , |
06 | Metal = 5 , |
07 | } |
08 | function elements:bynum(self, num) |
09 | for i, v in pairs (self) do |
10 | if num = = v then return i end |
11 | end |
12 | end |
bad argument #1 to 'pairs' (table expected, got number) stack traceback:
You do not need the "self" in the functions parameters