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

abort()shared
Aborts the current pipeline action.
find(id)shared
Find a pipeline with a specified ID.
Include a filename using a specified pipeline.
Include all files in a folder using a specific pipeline, in alphabetical order.
Checks if the current pipeline has been aborted.
Registers a new pipeline with the specified ID and callback.

Functions

Pipeline.abort()

shared lib/pipeline.lua:44

Aborts the current pipeline action. To be handled by callbacks individually.

Pipeline.find(id)

shared lib/pipeline.lua:39

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

Pipeline.include(pipe, file_name)

shared lib/pipeline.lua:68

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

Pipeline.include_folder(id, directory)

shared lib/pipeline.lua:98

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

Pipeline.is_aborted()

shared lib/pipeline.lua:50

Checks if the current pipeline has been aborted.

Returns

  • Boolean is aborted

Pipeline.register(id, callback)

shared lib/pipeline.lua:29

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)

Defined in