include

From Garry's Mod
Jump to: navigation, search
 include( )

Contents

Description

Executes a Lua script.

NOTE

Addon files (.gma files) do not support relative parent folders (.. notation).

WARNING

The file you are attempting to include MUST NOT be empty or the include will fail. Files over a certain size may fail as well.

WARNING

If the file you are including is clientside or shared, it must be AddCSLuaFile'd or this function will error saying the file doesn't exist.

BUG

pcalling this function will break autorefresh.

Issue Tracker: #1976

Arguments

string fileName

The name of the script to be executed. The path must be either relative to the current file, or be an absolute path (relative to and excluding the lua/ folder).

NOTE

Please make sure your file names are unique, the filesystem is shared across all addons, so a file named "lua/config.lua" in your addon may be overwritten by the same file in another addon.

Returns

vararg

Anything that the executed Lua script returns.

Examples

Example

Demonstrates correct and incorrect usage.

-- Correct usage:
-- Will look for "lua/myLuaFolder/myLuaFile.lua" in all addons and then the base game lua/ folder
include( "myLuaFolder/myLuaFile.lua" )

-- This is incorrect, and will NOT work
include(               "lua/myLuaFolder/myLuaFile.lua" )
include(         "addons/lua/myLuaFolder/myLuaFile.lua" )
include( "addons/MyAddon/lua/myLuaFolder/myLuaFile.lua" )
include(       "MyAddon/lua/myLuaFolder/myLuaFile.lua" )


Personal tools
Navigation