|
| 20 Jun 2015 05:56 PM |
Well.. I'm looking for how do you get the position of an object in a table but I guess it's the same
for example, I want to find what number "String" is in a table. How? Thank you |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Jun 2015 05:58 PM |
for key = 1, #tbl do if tbl[key] == "String" then print(key); break; end end |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 05:58 PM |
Assuming no duplicates and the indexes are numerical
function getIndex(tab, value) for i, v in pairs(tab) do if value == v then return i; end end return -1; end |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 05:59 PM |
| Erm, #tab is better than ipairs(tab), just rememberd |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jun 2015 06:06 PM |
you were born to script
i can't tell if that's really amusing or sarcastic or just random or extremely pretentious |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Jun 2015 06:07 PM |
| Wow very on-topic comment /sarcasm |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 06:08 PM |
i am not socially inept u dont need a /sarcasm tag so i can understand
|
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 20 Jun 2015 06:08 PM |
| I think he needed to add some attributes though |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 06:09 PM |
| My name isn't "IKnowAllAboutScript".. it is "Born2Script". And people learn thing everyday. Deal with it. I have more threads incoming |
|
|
| Report Abuse |
|
|
acidflip
|
  |
| Joined: 18 Jul 2012 |
| Total Posts: 886 |
|
|
| 20 Jun 2015 06:36 PM |
"My name isn't "IKnowAllAboutScript".. it is "Born2Script". And people learn thing everyday. Deal with it. I have more threads incoming"
read the god damn wiki before posting all of your questions here |
|
|
| Report Abuse |
|
|