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: Table inside a hash?

Previous Thread :: Next Thread 
wackeyhd5cool is online. wackeyhd5cool
Joined: 24 Nov 2010
Total Posts: 906
30 Oct 2016 08:33 AM
script:
local hash = {["one"] = {1,"P1"}, ["two"] = {2,"P2"}}

for some reason, calling hash[1] and hash[2] are nil, however, in the pairs loop, the indices are "one" and "two", and the values are table: 1F059AC8 and table: 1F059588. Why is hash[1] and hash[2] nil?


r+
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
30 Oct 2016 08:37 AM
############################################################################################################################################################################################################################################################################################################################
Report Abuse
Praelance is not online. Praelance
Joined: 18 Oct 2016
Total Posts: 607
30 Oct 2016 08:37 AM
the array and dictionary parts of a table are different

"one" is the key, not [1], [1] is nil

you use a generic for loop as you've found when you need to access the dictionary portion


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
30 Oct 2016 08:39 AM
http://
pastebin.
com/
2sdq2QJz
Report Abuse
Praelance is not online. Praelance
Joined: 18 Oct 2016
Total Posts: 607
30 Oct 2016 08:40 AM
"where keys are stored as STRINGS"

not limited to that

can be userdata


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
30 Oct 2016 08:42 AM
??? Lol are you serious

You cant store userdatum as a key
In lua you can only have string and number keys to tables and userdatum
You can store userdata AT THAT KEY, but not AS THE KEY
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
30 Oct 2016 08:43 AM
An example is getChildren which returns an array of objects:

{
Workspace,
Baseplate,
Terrain
}

Or also indexing

print(game.Workspace)
print(game["Workspace"])
Report Abuse
Praelance is not online. Praelance
Joined: 18 Oct 2016
Total Posts: 607
30 Oct 2016 08:44 AM
local part = workspace.Part local tab = {} tab[part] = "test" print(tab.part)

yes i am serious


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
30 Oct 2016 08:47 AM
Still wrong

local t = {}
t[game] = "hi"
print(t.game)
--nil
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
30 Oct 2016 08:48 AM
o wait kek

local t = {} t[game] = "hi" print(t[game]) you did it wrong
Report Abuse
Praelance is not online. Praelance
Joined: 18 Oct 2016
Total Posts: 607
30 Oct 2016 08:49 AM
> local tesst = Instance.new("Part") local tab = {} tab[tesst] = "3" for key, value in pairs(tab) do print(key.Position) end
0, 0, 0



Report Abuse
Praelance is not online. Praelance
Joined: 18 Oct 2016
Total Posts: 607
30 Oct 2016 08:53 AM
my point was that tab.part was going to be nil

i am right


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