So, I am developing a community resource (that will soon be available) called: “BT (better table)”
In the process I encountered a “bug” in the code that do not want to work as intended, it will deleate an index but set to “nil” another, I need help, please, and thanks for everyone.
Remove code:
tbl.remove = function(Arguments: any, tableInst)
if tableInst == nil then tableInst = tbl end
if tableInst[0] then
task.spawn(function()
for i,v in pairs(tableInst[0]) do
if type(v) == "table" then
--It's a table
for j,k in pairs(v) do
if type(Arguments) == "table" then
for l,m in pairs(Arguments) do
if tostring(m) == tostring(k) then
print("have to remove here")
end
end
else
if tostring(k) == tostring(Arguments) then
print("have to remove here")
end
end
end
else
--It's not a table
if type(Arguments) == "table" then
for j,k in pairs(Arguments) do
if tostring(k) == tostring(v) then
tableInst[0][i] = nil --This does "deleate" an index but not the numeric one
end
end
else
if tostring(v) == tostring(Arguments) then
print("have to remove here.")
end
end
end
end
end)
end
end
Run code:
local bt = BT.new()
bt.add({"hey", "how's going?", 12041, Vector3.one})
bt.remove({"hey", 12041})
print(bt)
Output: