|
| 12 Sep 2015 04:39 PM |
How would I give each value within a table a number value to retrieve for later purposes?
My visual: local table = { 1234123 = 1, 45435 = 2 --and so on } |
|
|
| Report Abuse |
|
|
Everment
|
  |
| Joined: 08 Oct 2009 |
| Total Posts: 6020 |
|
|
| 12 Sep 2015 04:42 PM |
local table = { [1234123] = 1, [45435] = 2 }
Lua's fun when it comes to defining tables. If you put square brackets around something and set it equal to something, inside of a table, then whatever's in the brackets is the index of whatever value give it. My point: "local t = { ["asdf"] = 1337 }" is the same as "local t = {} t["asdf"] = 1337" (and it takes up the same amount of characters because i do spacing in tables like that" |
|
|
| Report Abuse |
|
|
|
| 12 Sep 2015 04:44 PM |
| Awesome. How would I grab the number? For example, if I were to chose a random value from the table, how would I get '1' or '2'? |
|
|
| Report Abuse |
|
|
Everment
|
  |
| Joined: 08 Oct 2009 |
| Total Posts: 6020 |
|
|
| 12 Sep 2015 04:45 PM |
table[1234123] would result in 1 table[45435] would result in 2 |
|
|
| Report Abuse |
|
|
|
| 12 Sep 2015 04:47 PM |
| So it would print the number 1 or 2 or whatever the number is next to the value? Sorry i'm getting confused, that number is important. |
|
|
| Report Abuse |
|
|
| |
|