I’m running into a situation where I have conflicting variable names. The issue stems from the fact that I tend to use descriptive name which indicates what the variable is being used for. The problem is that I have a local variable defined in a function that shadows a top (script) level variable of the same name. What I would like to do is access the top level variable from the function. I have done this in C++ by doing this:
int someVar = 42
void someFunction(void)
{
int someVar = 24
::someVar = someVar
}
This uses the scope operator to access the shadowed variable in the global context instead of the local variable.
Can this be done in LUA? If so, how? I tried using the scope operator but it errors out. I don’t know what the syntax looks like.
local someVar = 42
local function someFunction()
local someVar = 24
::someVar = someVar -- Error
end
The above code is what I tried.