a.lua code is
Code: Select all
a=1200
dofile("b.lua")
c=200
Code: Select all
a=100
Code: Select all
a=1200
a=100
c=200
a=100
c=200 in a.lua right... and in b.lua, 'a' was not nil, but 1200 before 100 was set.
Exactly like that right?
Moderators: Shine, Insert_witty_name
Code: Select all
a=1200
dofile("b.lua")
c=200
Code: Select all
a=100
Code: Select all
a=1200
a=100
c=200
Code: Select all
x=100
b=x
x=nil
Code: Select all
a = 10
function blabla()
local a = 5
print(a)
end
blabla()
print(a)
Code: Select all
x=nil
Is there a way to copy the contents of x into b, not have b linked to x?But if you write "x={10};b=x;b[1]=2", then x[1] has the value 2, because {10} creates an object and saves the reference to x, then a reference to the same object is stored as b in the hashmap.
Code: Select all
function copy(x)
local y = {}
for i = 1, table.getn(x) do
y[i] = x[i]
end
return y
end