I’m getting this “error” (the script runs fine, and it doesn’t cause any bugs): “using ‘#’ on a table without an array part is likely a bug”
Here’s an example of where I’m getting it:
for i = 1, (currentEnemySupport and currentEnemySupport[1] and #currentEnemySupport) or 1, 1 do
if currentEnemySupport[i] ~= nil then
...
end
end
The #currentEnemySupport gets underlined red and lights up everywhere in my script as an error which is very annoying to look at. Basically my currentEnemySupport
variable is either a singular table/dictionary which is a card variable, or it’s an array of multiple support cards.
The checks before using the #
on the table make sure that it’s an array rather than a singular card/dictionary so this won’t ever cause any issues, so I need to know how to get rid of these error lines as I use this same check in many places.
Here’s where I assign the variables for currentEnemySupport
:
function BattleClient.SetupCurrentSupports() -- setup supports
if currentPlayerCard == nil or currentEnemyCard == nil then return end
local slotNumber = currentPlayerCard.SlotNumber
local eSlotNumber = currentEnemyCard.SlotNumber
if enemySupportCards[eSlotNumber] then
if not enemySupportCards[eSlotNumber][1] then
currentEnemySupport = {enemySupportCards[eSlotNumber]}
else
currentEnemySupport = enemySupportCards[eSlotNumber]
end
else
currentEnemySupport = {}
end
if playerSupportCards[slotNumber] then
if not playerSupportCards[slotNumber][1] then
currentPlayerSupport = {playerSupportCards[slotNumber]}
else
currentPlayerSupport = playerSupportCards[slotNumber]
end
else
currentPlayerSupport = {}
end
end
(I use the same checks for currentPlayerSupport
and don’t get the error lines so I have no idea what’s wrong.
I’ve messed with a few of the studio settings but can’t find any that disable the error lines. But I also don’t want to disable all errors lines because usually they’re correct and there’s an error