From GMod Wiki
module( String Module Name, Table ... )
Where is this used?
|Creates a table called moduleName and changes the environment to that table|
|Part of Library:||Global Functions|
|BBCode Link:||[b][url=http://wiki.garrysmod.com/?title=G.module]G.module [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]|
- module changes the environment from the global to inside the module, this has advantages in that you don't have to define functions as function iterators.AllKeys(), just as function AllKeys(), but it means you can't access globals
- package.seeall allows you to use globals from inside the module, but the globals are then stuck in it, which could cause problems, for example if someone made an addon that let you enter lua in-game and decided that the best way to stop people using functions they shouldn't they are placed in an environment with only basic lua commands. If the module created with package.seeall was included you could access all the lua commands by iterators._G[function_name].
- for a way of accessing the globals while still not polluting the namespace, see http://lua-users.org/wiki/ModuleDefinition