I\'m trying to get a string with multiple numbers to a single int like this:
x=\"5+5\" --amount of numbers is not constant y=tonumber(x) print(y)
tonumber can be used only on a string that is a real number, not an arithmetic expression.
tonumber
You can load the string and run it:
x = "5 + 5" func = assert(load("return " .. x)) y = func() print(y)
In Lua 5.1, use loadstring instead of load.
loadstring
load