Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 9 10 11 12 13 … 18 Next »
Non exists entry returns true
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
Non exists entry returns true
12-06-2016, 09:07 PM,
#4
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Non exists entry returns true
In your loop:
for i=1, #t do
if(t[i] == entry) then
print(t[i])
table.remove(t,i)
end
end
The variable i is shadowing the value you defined above. When you use table.remove, it removes the value at the index i, which is a number due to the loop. This does not remove the value you stored under window.activeWindows[ "Users" ], hence you get true.

Also, table length through #Table measures the size of the array part of a table. That is, it counts the number of values in a sequence starting at index 1. Thus, non-array indices (such as strings) do not get counted.

You need to do:
t[ entry ] = nil
table.remove( t, i )
to remove both the value in the array part, and the string indexed value.
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
Non exists entry returns true - by LocInt - 12-06-2016, 08:56 PM
RE: Non exists entry returns true - by Person8880 - 12-06-2016, 08:59 PM
RE: Non exists entry returns true - by LocInt - 12-06-2016, 09:02 PM
RE: Non exists entry returns true - by Person8880 - 12-06-2016, 09:07 PM
RE: Non exists entry returns true - by LocInt - 12-06-2016, 09:12 PM
RE: Non exists entry returns true - by Person8880 - 12-06-2016, 09:13 PM
RE: Non exists entry returns true - by LocInt - 12-06-2016, 09:14 PM
RE: Non exists entry returns true - by Person8880 - 12-06-2016, 09:22 PM

  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.