-- Chapter 21 example: a local inside the function resets every call.

local function counter_step()
    local count = 0
    count = count + 1
    return count
end

print(counter_step())   -- 1
print(counter_step())   -- 1
print(counter_step())   -- 1

-- A variable OUTSIDE the function is shared across calls:

local count = 0

local function step()
    count = count + 1
    return count
end

print(step())   -- 1
print(step())   -- 2
print(step())   -- 3
