Would all this get stores in the player table even though it has a .x or .y? When I was learning tables I could have sworn that to store something into the table it would have to use the same name like.. player = whatever . Sorry for the horrible question.
Actually, that could would raise and error since lua is case sensitive, so player differs from Player. So, the dot refer to an object, which you want to store x, y and speed, but as I said before it'll raise an error as the object "Player" doesn't exists because you haven't declared it yet.
sinsiter wrote: ↑Sat Jul 29, 2017 7:12 pm
Another question. What's the difference between the two if they do the same thing?
The difference is almost none, sometimes you will find using .x = 0, .y = 0, .speed = 100 (easier to read), other times you will enjoy using {x = 0, y = 0, speed = 100} (initializing the table in one line of code).
P.S. At least in Lua 5.3 it should be {x = 0} not {"x" = 0} (which throws an error).
a = {
b = 5,
c = b -- or even a.b
}
-- The above code doesn't do what you expect it to (set a.c to 5 as well), as how the below code does it
a = {}
a.b = 5
a.c = a.b
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.