If you are always defining variables/functions at the top of the script to make it quicker to write then this may be good for you.
You can store all of the variables in a module and return a specific function to set your enviroment to the variables when called
Module -> Variables.lua
-- Required to be defined globaly centerX = display.contentCenterX centerY = display.contentCenterY actualW = display.actualContentWidth actualH = display.actualContentHeight originX = display.screenOriginX originY = display.screenOriginY return function() setfenv(2, getfenv()) end
Script
require('Variables')() -- should always be on the first line or it will wipe out all variables above it print(actualW,actualH)
This could also be used to make your code look cleaner.
Note: If you are using an editor with a syntax highligher this may not be good as it triggers it to think it’s undefined.
