Another important point about local variables is that they only exist whilst in scope whereas global variables are retained (unless you specifically set them to 'nil' then they are gone).
So if you define local inside a function when the function ends the variable and anything it was storing can be freed up.
Where this becomes important is with things like sprites, when you do something like this
dome_sprites = {}
function terrain_map_init(e)
local dome_img = LoadImage ( "scriptbank\\moon_lander\\dome.png")
dome_sprites = {{spr = CreateSprite(dome_img), entity = nil},
{spr = CreateSprite(dome_img), entity = nil},
{spr = CreateSprite(dome_img), entity = nil}}
end
The dome_img variable will be thrown away at the 'end' statement and the memory used freed up (at least it should if Lee has done it right .
)
The dome_sprites variable otoh is global so will live until you no longer require it when you can do 'dome_sprites = nil' and it should then be freed up.
Been there, done that, got all the T-Shirts!