I am trying to develop a function that does math with two values that have the same key:
property = {a=120, b=50, c=85} operator = {has = {a, b}, coefficient = {a = 0.45}} function Result(x) return operator.has.x * operator.coefficient.x end print (Result(a)) error: attempt to perform arithmetic on field 'x' (a nil value)
The problem is that the function mathematically tries literally "operator.has.x" instead of "operator.has.a".
I can call the function (x) return x.something end, but if I try the function (x) something.x, I get an error. I need to improve my understanding of functions in Lua, but I cannot find it in the manuals.
source share