lets say we have a table here:
fart = 1
bam = 18
doodad = 109
Instead of doing Table[2] is there a way to do something like Table[“bam”] or something?
lets say we have a table here:
fart = 1
bam = 18
doodad = 109
Instead of doing Table[2] is there a way to do something like Table[“bam”] or something?
I mean you got it,
Table = {
["Halo"] = 1
}
print(Table["Halo"])
or
Table = {
Halo = 1
}
print(Table["Halo"])
Let me give you an example. John and Mary will help me.
local players = {
John = {
age = 25,
favoriteColor = "Blue",
hobbies = {"Reading", "Swimming"}
},
Mary = {
age = 30,
favoriteColor = "Red",
hobbies = {"Cycling", "Drawing"}
}
}
print(players.John.age) -- This will display 25
print(players.Mary.hobbies[2]) -- This will display drawing
how would i do an if statment for this? i tried table.find but it does not work
local Table = {
Halo = 1
}
if Table["Jello"] then
print("Table Jello")
elseif Table["Halo"] then
print("Table Halo")
else
warn("Not here")
end
Table = {
"Halo": 1
}
if "Halo" in Table:
print(Table["Halo"])
else:
print("Key not found")
that works, thank you!!!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.