|
| 23 Feb 2015 06:29 PM |
Script:
local Table = {1,2,3} table.sort(Table) for i,v in ipairs(Table) do print (i,v) end
Output:
1 1 2 2 3 3
How would I get it to just display only 1 of those values, like 2? |
|
|
| Report Abuse |
|
|
Stefan631
|
  |
| Joined: 23 Dec 2010 |
| Total Posts: 1350 |
|
|
| 23 Feb 2015 06:33 PM |
local t = {1; 2; 3}; for _, v in pairs(t) do if v == 2 then print(_, v); end; end;
|
|
|
| Report Abuse |
|
|
bomblover
|
  |
| Joined: 23 Mar 2011 |
| Total Posts: 238 |
|
|
| 23 Feb 2015 06:35 PM |
local Tab = {1,2,3,4,5,6,7,8,9}
for i,v in pairs(Tab) do if v == 2 then print("A two was found in the local table 'Tab'") end end |
|
|
| Report Abuse |
|
|
Stefan631
|
  |
| Joined: 23 Dec 2010 |
| Total Posts: 1350 |
|
| |
|
bomblover
|
  |
| Joined: 23 Mar 2011 |
| Total Posts: 238 |
|
|
| 23 Feb 2015 06:36 PM |
| @Stefan when outputting the index don't use a placeholder to represent it. |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2015 06:55 PM |
local Table = {Apple.Value, Banana.Value} table.sort(Table) for i,v in pairs(Table) do if v >= 1 then print (i,v); end end
So if any of the values are larger or equal to 1 it returns the key [1] or [2] and the value. How would I make it return the key's name: [1] = "Apple" with the given value change. |
|
|
| Report Abuse |
|
|
bomblover
|
  |
| Joined: 23 Mar 2011 |
| Total Posts: 238 |
|
|
| 23 Feb 2015 07:03 PM |
| Would you explain what you're trying to do/make? It's much easier to help you that way. |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2015 07:41 PM |
| Organize the values, and also provide the name of the Values |
|
|
| Report Abuse |
|
|
| |
|
| |
|