Skip to main content

Package

Class which represents the current Package

🗿Static Class
This is a Static Class. Access it's methods directly with .. It's not possible to spawn new instances.
💂Authority
This static class can be accessed on both 🟧 Client and 🟦 Server side.

Static Functions​

ReturnsNameDescription
ExportMakes any variable available in the global scope
anyRequireIncludes new .lua files
functionSubscribeSubscribes 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 stringGetDirectoriesGets a list of all directories in this package
table of stringGetFilesGets a list of all files in this package
stringGetNameReturns the package name/path
stringGetTitleReturns the package title
stringGetVersionReturns the package version
stringGetCompatibilityVersionReturns the package compatibility version
tableGetPersistentDataGets the Persistent Value from the disk

Export​

Makes any variable available in the global scope

Package.Export(variable_name, value)
TypeParameterDefaultDescription
stringvariable_nameName of the variable to export
anyvalueValue to be set in the global scope

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
stringscript_filePath to the script file to require

Subscribe​

Subscribes to an Event

— Returns function (The function callback).

local ret = Package.Subscribe(event_name, callback)
TypeParameterDefaultDescription
stringevent_nameEvent to subscribe to
functioncallbackCallback to run on the event occurring

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
stringevent_nameEvent to unsubscribe to
functioncallback?nilOptional callback to specifically unsubscribe to

SetPersistentData​

Sets a Persistent Value which will be saved to disk

Package.SetPersistentData(key, value)
TypeParameterDefaultDescription
stringkeyKey to index data into
anyvalueValue 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
stringpath_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 tablepath_filter?Path filter
stringextension_filter?Example : .lua

GetName​

Returns the package name/path

— Returns string (The package name/path).

local ret = Package.GetName()

GetTitle​

Returns the package title

— Returns string (The package title).

local ret = Package.GetTitle()

GetVersion​

Returns the package version

— Returns string (The package version).

local ret = Package.GetVersion()

GetCompatibilityVersion​

Returns the package compatibility version

— Returns string (The package compatibility version).

local ret = Package.GetCompatibilityVersion()

GetPersistentData​

Gets the Persistent Value from the disk

— Returns table (Persistent values from disk).

local ret = Package.GetPersistentData(key?)
TypeParameterDefaultDescription
string or nilkey?The key to get the data

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()
-- Load was called
end)

Unload​

Called when this package is unloaded
Package.Subscribe("Unload", function()
-- Unload was called
end)