For example, I would share the game name "Super Generic Adventure" around my code for various reasons, for example the window title, or the name of the folder with the save games inside.
I didn't started seriously to code with lua, but reading examples around make me think I should share these data with functions so something like this:
Code: Select all
-- File A
function getGameName()
return "Super Generic Adventure"
end
-- File B
function saveGameFile()
local gameName = getGameName()
-- do code to save game
end
-- File C
function setWindow()
local gameName = getGameName()
-- do code to set window size and title
end
I've noticed lua supports classes, so I suppose this is a must for who would write a well organized video game.