Passer au contenu principal
Version: latest - a1.64.x ⚖️

📦 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.
🧑‍💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

🗿 Static Functions

ReturnsNameDescription
ExportMakes any variable available in the global scope
FlushPersistentDataFlushes the Persistent Data pending changes to disk immediately
stringGetCompatibilityVersionReturns the package compatibility version
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
tableGetPersistentDataGets the Persistent Value from the disk
stringGetTitleReturns the package title
stringGetVersionReturns the package version
anyRequireIncludes new .lua files
SetPersistentDataSets a Persistent Value which will be saved to disk
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

Export

Makes any variable available in the global scope

Package.Export(variable_name, value)
TypeParameterDefaultDescription
stringvariable_name Required parameter Name of the variable to export
anyvalue Required parameter Value to be set in the global scope

FlushPersistentData

Flushes the Persistent Data pending changes to disk immediately

Package.FlushPersistentData()

GetCompatibilityVersion

Returns the package compatibility version

— Returns string (The package compatibility version).

local ret = Package.GetCompatibilityVersion()

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()

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

See also SetPersistentData.


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()

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, force_load)
TypeParameterDefaultDescription
stringscript_file Required parameter Path to the script file to require
boolean or nilforce_load Required parameter Whether to force loading this file even if it was already loaded

SetPersistentData

Sets a Persistent Value which will be saved to disk

Package.SetPersistentData(key, value)
TypeParameterDefaultDescription
stringkey Required parameter Key to index data into
anyvalue Required parameter Value to set at the key

See also GetPersistentData.


Subscribe

Subscribes to an Event

— Returns function (The function callback).

local ret = Package.Subscribe(event_name, callback)
TypeParameterDefaultDescription
stringevent_name Required parameter Event to subscribe to
functioncallback Required parameter Callback 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_name Required parameter Event to unsubscribe to
functioncallback?nilOptional callback to specifically unsubscribe to

🚀 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)