Skip to main content
Version: latest - a1.7.0 βš–οΈ

πŸ“¦ Package

Class which represents the Current Package

info

🟦🟧 Authority: This 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
WarnLogs and formats a warning message in the console in Orange
ErrorLogs and formats an error message in the console in Red
anyCallCalls an exported function from an other Package
Exportβ€˜Exports’ a function to be called from any other Package
RequireIncludes new .lua files
RequirePackageIncludes other Package in this Package
functionSubscribeSubscribes for an Event
UnsubscribeUnsubscribes from all subscribed Events in this Class and in this Package
SetPersistentDataSets a Persistent Value which will be saved to Disk
tableGetDirectoriesGets a list of all directories in this package
tableGetFilesGets a list of all files in this package
stringGetNameGives the package name
stringGetPathGives the package path
stringGetVersionGets the package version
tableGetPersistentDataGets all Persistent Values from the Disk

Events​

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

Functions Detailed​

Call​

Calls an exported function from an other Package

Returns any

Package.Call(package_name, function_name, args...)
TypeParameterDescription
stringpackage_name
stringfunction_name
anyargs...

Error​

Logs and formats an error message in the console in Red (the proper and nanos way)

Package.Error(message, ...)
TypeParameterDescription
stringmessage
anyargs...

Export​

'exports' a function to be called from any other package

Package.Export(function_name, callback)
TypeParameterDescription
stringfunction_name
functioncallback

Log​

Logs and formats a message in the console (the proper and nanos way)

Package.Log(message, ...)
TypeParameterDescription
stringmessage
anyargs...

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/
Package.Require(script_file)
TypeParameterDescription
stringscript_file

RequirePackage​

Includes other Package in this Package

Package.RequirePackage(package_name)
TypeParameterDescription
stringpackage_name

Subscribe​

Subscribes for an Event

Returns the function callback itself

Package.Subscribe(event_name, callback)
TypeParameterDescription
stringevent_name
functioncallback

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)
TypeParameterDefault ValueDescription
stringevent_name
functioncallbacknil

Warn​

Logs and formats a warning message in the console in Orange (the proper and nanos way)

Returns

Package.Warn(message, ...)
TypeParameterDescription
stringmessage
anyargs...

SetPersistentData​

Sets a Persistent Value which will be saved to Disk

Package.SetPersistentData(key, value)
TypeParameterDescription
stringkey
anyvalue

GetDirectories​

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

Returns table of string

Package.GetDirectories(path_filter)
TypeParameterDefault ValueDescription
stringpath_filter""

GetFiles​

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

Returns table of string

Package.GetFiles(path_filter, extension_filter)
TypeParameterDefault ValueDescription
stringpath_filter""
stringextension_filter""

GetName​

Gives the package name

Returns string

Package.GetName()

GetPath​

Gives the package path

Returns string

Package.GetPath()

GetVersion​

Gets the package version

Returns string

Package.GetVersion()

GetPersistentData​

Gets all Persistent Values from the Disk

Returns table of any

Package.GetPersistentData()

Events Detailed​

Load​

Called when this package is loaded

info

The event Load 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()
-- Package has been loaded
end)

Unload​

Triggered when this page fails to load

Package.Subscribe("Unload", function()
-- Package has been unloaded
end)