Require inside function...

I wonder if it is okay to use require inside a function, so it can be called with each new scene call?

I would like to use it this way to be able to load different modules if needed for example when the language on the device has changed. Normally you require only once, but is this okay to do?

Yes, because require won’t load a module again if it has already been require’d.

https://www.lua.org/pil/8.1.html

The other main job of require is to avoid loading the same file twice. For that purpose, it keeps a table with the names of all loaded files. If a required file is already in the table, require simply returns. The table keeps the virtual names of the loaded files, not their real names. Therefore, if you load the same file with two different virtual names, it will be loaded twice. For instance, the command require"foo" followed by require"foo.lua", with a path like “?;?.lua”, will load the file foo.lua twice. You can access this control table through the global variable _LOADED. Using this table, you can check which files have been loaded; you can also fool require into running a file twice. For instance, after a successful require"foo", _LOADED[“foo”] will not be  nil. If you then assign  nil  to _LOADED[“foo”], a subsequent require"foo" will run the file again.

Thanks for the info!

Yes, because require won’t load a module again if it has already been require’d.

https://www.lua.org/pil/8.1.html

The other main job of require is to avoid loading the same file twice. For that purpose, it keeps a table with the names of all loaded files. If a required file is already in the table, require simply returns. The table keeps the virtual names of the loaded files, not their real names. Therefore, if you load the same file with two different virtual names, it will be loaded twice. For instance, the command require"foo" followed by require"foo.lua", with a path like “?;?.lua”, will load the file foo.lua twice. You can access this control table through the global variable _LOADED. Using this table, you can check which files have been loaded; you can also fool require into running a file twice. For instance, after a successful require"foo", _LOADED[“foo”] will not be  nil. If you then assign  nil  to _LOADED[“foo”], a subsequent require"foo" will run the file again.

Thanks for the info!