Custom Packages
This sections explains custom packages and how to create them.
Creating custom packages allows you to expand Nowa by implementing your own functions, and commands. This page will walk you through the process of creating your own package.
Properties
Every user defined package must include the following properties:
title
The package title.
sub
The package subtitute title.
description
The package description.
parameters
The package parameters.
authority
The level of authority that a player requires to invoke the package. The first value is the authority type, this can either be rank or role. The second value is the value for the authority type.
triggerInitial
A trigger initial of a non-magic character in string that is required to invoke the package. This parameter overrides the admin prefix.
terminalEnabled
Determines whether or not the package can be invoked using the command bar or chat.
invoke()
The function to be called by the client. This is where you will write your own code.
Package Syntax
The default code of the package.
return
{
title = 'ExamplePackage',
sub = 'ep',
description = 'An example package',
parameters = '[parameter]',
authority = 'Rank,255',
triggerInitial = false,
terminalEnabled = true,
invoke = function(player: Player, args: {command: string, initial: string, raw: string, data: {args1: {}, args2: string}})
end,
}
Package parameters
.ExamplePackage(
player: Player,
args: {
command: string,
initial: string,
raw: string,
data: {
args1: {any},
args2: {any},
}
}
): any
player
The player that is invoking the packaging.
args
Passed arguments.
command
A command that the player requested to call.
initial
The first character of the request.
raw
The raw string of the request.
data
Any data that is passed to the package.
args1
The first argument of the data.
args2
The second argument of the data.
Code Samples
-- From LocalScript
game.TextChatService.OnIncomingMessage = function(message)
if message.TextSource.Name == game.Players.LocalPlayer.Name then
if message.Status == Enum.TextChatMessageStatus.Success then
RemoteFunction:InvokeServer('terminal-command-request', {messageData = message.Text})
end
end
end
-- From ExamplePackage
local MainPackages = require(script.Parent.Parent.MainPackages)
return
{
title = 'ExamplePackage',
description = 'An example package',
parameters = '[parameter]',
authority = 'Rank,255',
terminalEnabled = true,
invoke = function(player: Player, args: {command: string, initial: string, raw: string, data: {args1: {}, args2: string}})
local fullMessage = MainPackages.concatargs(args.data.args1, args.data.args2)
print(player.Name..' has executed '..args.command..' and said "'..fullMessage..'"')
end,
}
To test your new custom package, simply play test and say something like "ExamplePackage Hello World".
The first word will be recognized as a package and will then call the invoke function in your ExamplePackage.
Keep in mind:
Your arguments will be separated into two, args1, and args2, and will look like the following: Hello, World. To add them together, use the concatargs
main package. Learn more about main packages.