CompileFile

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

Contents

Description

Attempts to compile the given file. If successful, returns a function that can be called to perform the actual execution of the script.

Arguments

string path

Path to the file, relative to the garrysmod/lua/ directory.

Returns

function

The function which executes the script.

Examples

Example

Assuming our file is named example.lua and located in the garrysmod/lua/ directory, the following code would execute the script.

local example = CompileFile("example.lua")
example()

Output:

Hello!
Personal tools
Navigation