So, I’m making a Chess board system where you can put a FEN in and return white’s move and black’s move, the problem I’m having here is that when I try to sort these pieces into their tables the table.find() always return nil regardless what I do
local BlackPieces = {"p", "r", "n", "b", "q", "k"}
local WhitePieces = {"P", "R", "N", "B", "Q", "K"}
local function SortPieces(PieceCoordinates)
local WhitePieces = {}
local BlackPieces = {}
for _, PieceData in pairs(PieceCoordinates) do
if table.find(WhitePieces, PieceData[1]) then
table.insert(WhitePieces, PieceData[1])
elseif table.find(BlackPieces, PieceData[1]) then
table.insert(BlackPieces, PieceData[1])
end
print(PieceData[1], table.find(WhitePieces, PieceData[1]))
print(PieceData[1], table.find(BlackPieces, PieceData[1]))
end
return {WhitePieces, BlackPieces, PieceCoordinates}
end
and the PieceCoordinates is just an array that looks smt like this
{
{"r" ,{1,1}, {"n" ,{1,2}, {"b" ,{1,3},...
}
and this is what it print out
I made sure its not a dictionary but idk if the tables in the picture is a dictionary when I use table.insert()
and when I print out table.find(WhitePieces, "P") it returns nil instead of 1
I checked about this topic and theres seem to be nothing about it
