Skip to main content
Version: bleeding-edge 🩸

πŸ“¦ Package

Class which represents the current Package

πŸ’‚Authority
This static class can be accessed on both 🟧 Client and 🟦 Server.
πŸ—ΏStatic Class
This is a Static Class. You can access it's methods directly with .. It is not possible to initialize or create new instances.

πŸ—Ώ Static Functions​

ReturnsNameDescription
LogLogs and formats a message in the console, with formatted arguments
WarnLogs an orange warning in the console, with formatted arguments
ErrorLogs a red error in the console, with formatted arguments
any CallCalls an exported function from another Package
Export'Exports' a function to be called from any other Package
any RequireIncludes new .lua files
RequirePackageIncludes other Package in this Package
function SubscribeSubscribes to an Event
UnsubscribeUnsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
SetPersistentDataSets a Persistent Value which will be saved to disk
table of string GetDirectoriesGets a list of all directories in this package
table of string GetFilesGets a list of all files in this package
string GetNameGives the package name
string GetPathGives the package path
string GetVersionGives the package version
table GetPersistentDataGets all Persistent Values from the disk

Log​

Logs and formats a message in the console, with formatted arguments
Package.Log(message, args...?)
TypeParameterDefaultDescription
string messageMessage to print
any args...?nilOther arguments to format with the message using string.format

Warn​

Logs an orange warning in the console, with formatted arguments
Package.Warn(message, args...?)
TypeParameterDefaultDescription
string messageMessage to print
any args...?nilOther arguments to format with the message using string.format

Error​

Logs a red error in the console, with formatted arguments
Package.Error(message, args...?)
TypeParameterDefaultDescription
string messageMessage to print
any args...?nilOther arguments to format with the message using string.format

Call​

Calls an exported function from another Package

Returns any (Any return values from the called function)
local ret = Package.Call(package_name, function_name, args...?)
TypeParameterDefaultDescription
string package_nameName of the package to call
string function_nameName of the function to call from the package
any args...?nilArguments to pass to the function

Export​

'Exports' a function to be called from any other Package
Package.Export(function_name, callback)
TypeParameterDefaultDescription
string function_nameName of the function to export from the current package
function callbackFunction to be called by other packages

Require​

Includes new .lua files

We currently support 5 searchers, which are looked in the following order:
  1. Relative to current-file-path/
  2. Relative to current-package/Client/ or current-package/Server/ (depending on your side)
  3. Relative to current-package/Shared/
  4. Relative to current-package/
  5. Relative to Packages/


Returns any (Any return values from the included file)
local ret = Package.Require(script_file)
TypeParameterDefaultDescription
string script_filePath to the script file to require

RequirePackage​

Includes other Package in this Package
Package.RequirePackage(package_name)
TypeParameterDefaultDescription
string package_namePackage to require

Subscribe​

Subscribes to an Event

Returns function (The function callback)
local ret = Package.Subscribe(event_name, callback)
TypeParameterDefaultDescription
string event_nameEvent to subscribe to
function callbackCallback to run on the event occuring

Unsubscribe​

Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
Package.Unsubscribe(event_name, callback?)
TypeParameterDefaultDescription
string event_nameEvent to unsubscribe to
function callback?nilOptional callback to specifically unsubscribe to

SetPersistentData​

Sets a Persistent Value which will be saved to disk
Package.SetPersistentData(key, value)
TypeParameterDefaultDescription
string keyKey to index data into
any valueValue to set at the key

GetDirectories​

Gets a list of all files in this package, optionally with filters

Returns table of string (List of directories)
local ret = Package.GetDirectories(path_filter?)
TypeParameterDefaultDescription
string path_filter?Path filter

GetFiles​

Gets a list of all files in this package, optionally with filters

Returns table of string (List of files)
local ret = Package.GetFiles(path_filter?, extension_filter?)
TypeParameterDefaultDescription
string or table path_filter?Path filter
string extension_filter?Example : .lua

GetName​

Gives the package name

Returns string (The package name)
local ret = Package.GetName()

GetPath​

Gives the package path

Returns string (The package path)
local ret = Package.GetPath()

GetVersion​

Gives the package version

Returns string (The package version)
local ret = Package.GetVersion()

GetPersistentData​

Gets all Persistent Values from the disk

Returns table (Persistent values from disk)
local ret = Package.GetPersistentData()

πŸš€ Events​

NameDescription
LoadCalled when this package is loaded
UnloadCalled when this package is unloaded

Load​

Called when this package is loaded

This event is triggered differently depending on the situation:
  • When the server starts or you run package reload all the event triggers only after ALL packages are loaded.
  • In all other cases (package load/reload or Package.Load/Reload) the event is triggered immediately after the package is loaded/reloaded.
Package.Subscribe("Load", function()

end)

Unload​

Called when this package is unloaded
Package.Subscribe("Unload", function()

end)