Pipeline library
The Pipeline library lets you create systems that register their stuff via folders. It automatically does the boring stuff like converting filenames for you, requiring you to write the real thing only. Check out the sh_item and sh_admin libraries for examples.
Summary
Functions
Functions
Aborts the current pipeline action. To be handled by callbacks individually.
Find a pipeline with a specified ID. Case-sensitive.
Parameters
- id String pipeline ID
Returns
- Map pipeline data, or nil if there is no such pipeline
Include a filename using a specified pipeline. This automatically resolves server/client/shared realms, and automatically extracts the ID based on the filename (for example, "sh_test_file.lua" becomes "test_file" in the ID). After that if the pipe is a valid registered pipeline, the callback is called.
Parameters
- pipe String/Map pipeline ID, or the pipeline data from Pipeline.find
- file_name String path of the file to include
Include all files in a folder using a specific pipeline, in alphabetical order.
See documentation for Pipeline.include.
Parameters
- id String pipeline ID
- directory String folder relative to the LUA search path
Checks if the current pipeline has been aborted.
Returns
- Boolean is aborted
Registers a new pipeline with the specified ID and callback. The callback is called for every file included through the pipeline. It receives the ID extracted from the file name, the path of the file and the pipeline's data table.
Pipeline.register('item', function(id, file_name, pipe)
ITEM = ItemBase.new(id)
require_relative(file_name)
if Pipeline.is_aborted() then ITEM = nil return end
ITEM:register() ITEM = nil
end)
Parameters
- id String pipeline ID
- callback Function called as callback(id, file_name, pipe)