G.include

From GMod Wiki

Jump to: navigation, search
Function
Syntax include( String Filename )
Where is this used?
Description:
Runs a lua file
Returns: nil
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.include]G.include [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionIncludes "hello.lua".
Used onNewerShared.png
Code
include("hello.lua")
OutputN/A


DescriptionThis is something you DO NOT want to do. I call this cross-including, where one file includes another file, which includes the first file. Observe:
Used onNewerShared.png
Code
--init.lua:
include("hello.lua")
 
--hello.lua:
include("init.lua")
 
OutputGarry's Mod will throw an error, as shown below:


The files will continue to include each other, untill infinity and beyond. Garry's Mod will throw a rather strange error at you as well, mainly saying:

file.lua:linenumber: chunk has too many syntax levels
-- Error PARSING CLIENTSIDE file -------------------------
- File: file.lua
----------------------------------------------------------

The number is usually irrelevant as to the real root of the problem, so begin searching in this file, as well as included files for cross-including.

Additional notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox