Make a common utility file in Lua — Corona SDK

When we building an app or a game, we use a function very frequently and we need to make a common functions and constants. One thing is you can declare the variables globally and use anywhere or to make the code more efficient and more readable, you can make a common class to access all the functions and variable.

Create a new file utility.lua or any other name which you prefer and add the code like below

utility.lua

Then on any other lua file, where you want to use the function call like this

Using a utility file will be so convenient and easy to modify the code.

Happy Coding !

Like what you read? Give Ranjithkumar Matheswaran a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.