generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Giving tables values numbers

Previous Thread :: Next Thread 
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
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 is not online. 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
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
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 is not online. 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
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
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
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
12 Sep 2015 04:53 PM
Hello?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image