Skip to main content
Version: bleeding-edge ๐Ÿฉธ

๐Ÿ“ฆ 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
Makes any variable available in the global scope
Flushes the Persistent Data pending changes to disk immediately
Returns the package compatibility version
of Gets a list of all directories in this package
of Gets a list of all files in this package
Returns the package name/path
Gets the Persistent Value from the disk
Returns the package title
Returns the package version
Includes new .lua files
Sets a Persistent Value which will be saved to disk
Subscribes to an Event
Unsubscribes 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
variable_name Required parameter Name of the variable to export
value 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 (The package compatibility version).

local ret = Package.GetCompatibilityVersion()

GetDirectories

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

โ€” Returns of (List of directories).

local ret = Package.GetDirectories(path_filter?)
TypeParameterDefaultDescription
path_filter?Path filter

GetFiles

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

โ€” Returns of (List of files).

local ret = Package.GetFiles(path_filter?, extension_filter?)
TypeParameterDefaultDescription
or path_filter?Path filter
extension_filter?Example: .lua

GetName

Returns the package name/path

โ€” Returns (The package name/path).

local ret = Package.GetName()

GetPersistentData

Gets the Persistent Value from the disk

โ€” Returns (Persistent values from disk).

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

See also SetPersistentData.


GetTitle

Returns the package title

โ€” Returns (The package title).

local ret = Package.GetTitle()

GetVersion

Returns the package version

โ€” Returns (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 return values from the included file).

local ret = Package.Require(script_file, force_load)
TypeParameterDefaultDescription
script_file Required parameter Path to the script file to require
or force_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
key Required parameter Key to index data into
value Required parameter Value to set at the key

See also GetPersistentData.


Subscribe

Subscribes to an Event

โ€” Returns (The function callback).

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

๐Ÿš€ Eventsโ€‹

NameDescription
Called when this package is loaded
Called 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)