pipeline library
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
Functions
Returns a registered pipeline.
Parameters
- id String Pipeline ID
Returns
- Map The pipeline table with
callbackanduniqueIDkeys, ornilif none is registered
pipeline.Include(pipe, fileName)
shared gamemodes/catwork/gamemode/core/libraries/sh_pipeline.lua:62Loads 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:91Loads 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:38Registers 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), whereuniqueIDis derived from the file name andpipeis the pipeline table