I don't under stand why lua is changing both variables even though my understanding is that the one out side the functions should not be touched.
What is going on and how do I keep the 'attacker' variable unchanged?
Thanks!
local attacker = { 0,-1 }
local function test()
local hitPattern = attacker
print( "----------->> attacker", # attacker )
--Set Loop Method
if hitPattern[ # hitPattern ] == -1 then
hitPattern[ # hitPattern ] = nil
end
print( "----->> attacker", # attacker )
end
test()
----------->> attacker 2
----->> attacker 1