Foundations
Tables
Tables keep related values together and let code read values by index.
Tables
tables.lua
local scores = {82, 91, 76}
local bonus =
local firstScore = scores[1]
local adjustedScore = scores[2] + bonus
print("first=" .. firstScore)
print("adjusted=" .. adjustedScore)
local scores = {82, 91, 76}
local bonus =
local firstScore = scores[1]
local adjustedScore = scores[2] + bonus
print("first=" .. firstScore)
print("adjusted=" .. adjustedScore)
local scores = {82, 91, 76}
local bonus =
local firstScore = scores[1]
local adjustedScore = scores[2] + bonus
print("first=" .. firstScore)
print("adjusted=" .. adjustedScore)
table index
Lua table indexes usually start at one, so `scores[1]` reads the first value.