|
| 08 Apr 2014 12:30 AM |
if table[1] == nil then ?
i'm asian |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 08 Apr 2014 12:32 AM |
You can't really, the only _true_ way is:
local stuff = #table for index, value in next, table do stuff = stuff + 1 end |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
| |
|
|
| 08 Apr 2014 04:30 AM |
Table = {}
if #Table == 0 then --Code end
Your telling me this wouldn't work? |
|
|
| Report Abuse |
|
|
M39a9am3R
|
  |
| Joined: 10 Nov 2012 |
| Total Posts: 1933 |
|
|
| 08 Apr 2014 04:36 AM |
| I've used war's method before, it works. |
|
|
| Report Abuse |
|
|
| |
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 08 Apr 2014 12:41 PM |
Nope.
Test this
table = {Pandas = 12}
print(#table) |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 08 Apr 2014 12:44 PM |
#table is fine.
table[1] is an intersting way, try it! |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 08 Apr 2014 12:46 PM |
@smiley test my code first and then tell me if it works.
And the same thing with table[1]. table[1] could be nil but table[2] might not be. |
|
|
| Report Abuse |
|
|
makerror
|
  |
| Joined: 29 Aug 2011 |
| Total Posts: 493 |
|
|
| 08 Apr 2014 12:48 PM |
t = {h,"hello",lol = 90} print(t[1]) |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 08 Apr 2014 12:49 PM |
And before anyone tries this this will not work either
if table == {} then
^That's like saying
if workspace.Part == Instance.new("Part") then
|
|
|
| Report Abuse |
|
|
| |
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 08 Apr 2014 12:53 PM |
@war
> table = {Panda = 12} print(#table) 0 |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 01:02 PM |
That is because your putting in a nil value...
How do you cycle through nil values of a table?
|
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 08 Apr 2014 01:07 PM |
Its not a nil value. This is what I'm doing
table = {Panda = 12} is equivalent to
table["Panda"] = 12
or table = {["Panda"] = 12}
Also, if you think this is the case, try this
table = {} table[2] = 12 print(#table) > 0
And you use for i, v in pairs(table) do |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 01:26 PM |
Sorry. Never noticed you were assigning a variable. I'm dumb.
If that is the case, you were using a dictionary, I don't have a clue how to figure out how many variables are in a dictionary |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 01:27 PM |
| Aren't you supposed to use ipairs? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 08 Apr 2014 06:52 PM |
-.-
Just use mine even though mine isn't going to show keys with nil values. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 08 Apr 2014 06:53 PM |
| War, a "dictionary" is just a table without all numerical-based keys. |
|
|
| Report Abuse |
|
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 08 Apr 2014 06:54 PM |
if table == nil then --code end |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 06:55 PM |
| #table works perfectly, if its 0 then the table is empty. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 08 Apr 2014 07:56 PM |
@dog try this
table[2] = "LOL" print(#table) gg. |
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 08 Apr 2014 08:00 PM |
| Even concat fails there, though would you often assign something to position 1 without assigning to 0? |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 08:04 PM |
I didn't think there was a position 0 in rbx Lua
i'm asian |
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 08 Apr 2014 08:07 PM |
err, my bad 2 and 1 I meant |
|
|
| Report Abuse |
|
|