Inside a function (doloadstring), I noticed that loadstring, even when a correct string is passed, will not modify a function variable. What gives?
My guess is x is a local variable and loadstring only has global scope?`
print('this works as I expect')
x = 0
loadstring('x = 1')()
print(x)
print('this does not')
function doloadstring(x, s)
print(x)
loadstring(s)() -- loadstring does not appear to change a variable in a function, is it because x is local
print(x)
print(z)
end
doloadstring('0', 'x = 1') -- x is not changed
doloadstring('0', 'z = 1') -- z is created tho
This is the output:
this works as I expect
1
this does not
0
0
nil
0
0
1