I went ahead and finished it
Its not super efficient because I didn't want to do so much typing so I just put my check in a function, but you get the idea and with something as simple as this (I mean processing wise, I'm not trying to talk bad about you OP) you don't really need to worry about that.
local tic = {
{1, 2, 1};
{2, 2, 1};
{0, 2, 0};
}
local function check(x, y, z)
return (((tic[tonumber(tostring(x):sub(1, 1))][tonumber(tostring(x):sub(2, 2))] == tic[tonumber(tostring(y):sub(1, 1))][tonumber(tostring(y):sub(2, 2))]) and (tic[tonumber(tostring(y):sub(1, 1))][tonumber(tostring(y):sub(2, 2))] == tic[tonumber(tostring(z):sub(1, 1))][tonumber(tostring(z):sub(2, 2))])) and (tic[tonumber(tostring(x):sub(1, 1))][tonumber(tostring(x):sub(2, 2))] ~= 0));
end
local function getMatch()
if (check(11, 12, 13)) then
print(((tic[1][1] == 1) and "x" or "o") .. " across top")
elseif (check(21, 22, 23)) then
print(((tic[2][1] == 1) and "x" or "o") .. " across middle")
elseif (check(31, 32, 33)) then
print(((tic[3][1] == 1) and "x" or "o") .. " across bottom")
elseif (check(11, 21, 31)) then
print(((tic[1][1] == 1) and "x" or "o") .. " down left")
elseif (check(12, 22, 32)) then
print(((tic[1][2] == 1) and "x" or "o") .. " down middle")
elseif (check(13, 23, 33)) then
print(((tic[1][3] == 1) and "x" or "o") .. " down right")
elseif (check(11, 22, 33)) then
print(((tic[1][1] == 1) and "x" or "o") .. " across from top left")
elseif (check(31, 22, 13)) then
print(((tic[3][1] == 1) and "x" or "o") .. " across from bottom left")
end
end
print(getMatch()) |