0

I am trying to create parts of tables many times but with different arguments. To do so, I have created a new function that takes a parameter, which is then used in a function in the table. My IDE shows the use of the parameter value inside the function as an "Up-value" problem.

Is there any way I can achieve this functionality without that issue?

function createTable(value)
    myTable = {
        name = 'Table',
        args = {
            time = 0,
            score = {
                function()
                    return value / 2
                end
            },
        },
    }
    return myTable
end
  • Your function returns a constant. Could just make that `score = value / 2` and avoid the function? Upvalues aren't a "problem", they are a legitimate feature of Lua. – Luatic Aug 06 '22 at 08:24
  • What exactly should the function return? A constant? – Egor Skriptunoff Aug 06 '22 at 09:13
  • 1
    I'm quite sure your IDE does not show you "an up-value problem". if you get an error message, quote it. don't put into your own words discarding 90% of the information – Piglet Aug 06 '22 at 13:50
  • I see that my example while simpler might not have been exactly equal to what I want. What my function actually should return is some value in table such as myTable[value].health – Christopher Kas Aug 07 '22 at 21:06

0 Answers0