Code: Select all
--tts = table to string
function tts(tile)
local str = "{"
for i,v in pairs(tile) do
if v == "x" then
str = str .. tile[i] .. ","
else
str = str .. "-,"
end
if i == 3 or i == 6 then
str = str .. "\n"
end
end
print(str .. "\n")
end
function love.load()
for i=1, 9, 1 do
local tl2 =
{"", "", "",
"", "", "",
"", "", ""}
tl2[i] = "x"
tts(tl2)
end
end
Second code
Code: Select all
--tts = table to string
function tts(tile)
local str = "{"
for i,v in pairs(tile) do
if v == "x" then
str = str .. tile[i] .. ","
else
str = str .. "-,"
end
if i == 3 or i == 6 then
str = str .. "\n"
end
end
print(str .. "\n")
end
function love.load()
tl =
{"", "", "",
"", "", "",
"", "", ""}
for i=1, 9, 1 do
local tl2 = tl
tl2[i] = "x"
tts(tl2)
end
end
i was expecting the same result, but instead its completely different, what is happening here?