Difference between revisions of "Require"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
m (Text replacement - "</source>" to "</syntaxhighlight>")
Line 7: Line 7:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
require(packagename)
 
require(packagename)
</source>
+
</syntaxhighlight>
  
 
Roughly, '''require''' does the same job as [[dofile]] but '''require''' searches for the file in a path. Because of that, '''require''' is the preferred function in Lua for loading libraries.
 
Roughly, '''require''' does the same job as [[dofile]] but '''require''' searches for the file in a path. Because of that, '''require''' is the preferred function in Lua for loading libraries.

Revision as of 14:32, 13 July 2023

Available since: Gideros 2011.6
Class: (global)

Description

Loads and runs libraries.

require(packagename)

Roughly, require does the same job as dofile but require searches for the file in a path. Because of that, require is the preferred function in Lua for loading libraries.

Parameters

packagename: (string) library to load

See also

Loading Order of Lua Files