Defines the global pipeline library, which lets a system register its content from a folder of Lua files.

pipeline.Register stores a callback under a pipeline ID, and pipeline.Include and pipeline.IncludeDirectory call it for each file with a unique ID derived from the file name (extension and cl_, sh_ or sv_ prefix removed).

Backported from the Flux project.

Summary

Functions

Find(id)shared
Returns a registered pipeline.
Loads a single file through a pipeline.
Loads every file in a directory through a pipeline.
Registers a pipeline that loads files through a callback.

Functions

Returns a registered pipeline.

Parameters

  • id String Pipeline ID

Returns

  • Map The pipeline table with callback and uniqueID keys, or nil if none is registered

pipeline.Include(pipe, fileName)

shared gamemodes/catwork/gamemode/core/libraries/sh_pipeline.lua:62

Loads a single file through a pipeline.

The file's unique ID is its file name without .lua, passed through MakeID, with a cl_, sh_ or sv_ prefix removed. Does nothing when the pipeline is not found, the file name is shorter than 7 characters or the resulting ID is empty.

Parameters

  • pipe String Pipeline ID, or the pipeline table itself
  • fileName String Path of the Lua file

pipeline.IncludeDirectory(uniqueID, directory)

shared gamemodes/catwork/gamemode/core/libraries/sh_pipeline.lua:91

Loads every file in a directory through a pipeline.

Only files directly inside the directory are loaded, in descending name order; subdirectories are skipped. Does nothing when the pipeline is not registered.

Parameters

  • uniqueID String Pipeline ID
  • directory String Directory path relative to the Lua mount, with or without a trailing slash

pipeline.Register(uniqueID, callback)

shared gamemodes/catwork/gamemode/core/libraries/sh_pipeline.lua:38

Registers a pipeline that loads files through a callback.

The callback is called by pipeline.Include for every file loaded through the pipeline.

pipeline.Register('item', function(uniqueID, fileName, pipe)
  ITEM = item.New(uniqueID)

  util.Include(fileName)

  ITEM:Register() ITEM = nil
end)

Parameters

  • uniqueID String Pipeline ID
  • callback Function Called as callback(uniqueID, fileName, pipe), where uniqueID is derived from the file name and pipe is the pipeline table

Defined in