As the Lua manual says, newbies to the language fall into the trap of thinking both a.x and a[x] are more alike than different. I am one of those newbies, ahaha.
Why does a.x give nil in this, but a[x] gives 10 and a.x gives nil?
a ={}
x = "y"
a[x] = 10
print(a[x]) --gives 10 for "y"
print(a.x) --gives nil for "x"
print(a.y) --give 10 for "y"
To be honest, I feel like I understand why the code above works, but I really want to know—conceptually— why:
invitems = {}
name = string.lower(name)
invitems[name] = "weapon"
print(invitems[name]) ----> gives weapon
print(invitems.name) ----> gives nil
print(invitems.string.lower(name)) ----> gives weapon