Adding Commands To A Plugin - EdgeIY/infiniteyield GitHub Wiki

If you want to test any commands you make to see if they error, run the debug command in Infinite Yield so errors actually get sent to console. This command does not show up in the command list, just type it and press enter.

* * *

Once you have a plugin setup, you are ready to start adding commands in the Commands table. Each command is a key in the table that is usually named the command.

Here is the keys for each command table:

  • <string> ListName : This is where you put your command (along with arguments in square brackets). You can show the user and aliases here too.
  • <string> Description : The message you want to appear when the user clicks the command in the list for more information.
  • <table> Aliases : This is the aliases that you can use to run the command. Make sure that the table is sorted and each element of the table is an alias for your command. If you don't want to create any aliases for your command, leave this table empty.
  • <function> Function : This is the function that is executed when the user runs your command.

Arguments:

  1. <table> args : A table containing the arguments passed into the command
  2. <Player> speaker : The user's player object. Such as: game:GetService("Players").LocalPlayer

Note: Infinite Yield contains global functions that you can use in commands. These are covered in the Core Functions section of this Wiki.

Each command should follow this format:

-- Note: This is just a snippet
["EXACTCOMMAND"] = {
    ["ListName"] = "COMMAND [ARGUMENT]",
    ["Description"] = "DESCRIPTION HERE",
    ["Aliases"] = {"ALIAS1", "ALIAS2", "ALIAS3"},
    ["Function"] = function(args, speaker)
        -- CODE
    end
}

Here is an example:

local Plugin = {
    ["PluginName"] = "ExamplePlugin",
    ["PluginDescription"] = "This is a helpful template",
    ["Commands"] = {
        ["print"] = {
            ["ListName"] = "print [text]",
            ["Description"] = "Outputs text to the Roblox console",
            ["Aliases"] = {"p", "out", "output"},
            ["Function"] = function(args, speaker)
                print(getstring(1, args))  
            end
        },
        ["notify"] = {
            ["ListName"] = "notify [text]",
            ["Description"] = "uses the notification function",
            ["Aliases"] = {"alert"},
            ["Function"] = function(args, speaker)
                notify("Notification Title", getstring(1, args))
            end
        }
    }
}

return Plugin

If you are struggling, feel free to use my template:

local Plugin = {
    ["PluginName"] = "NAME HERE",
    ["PluginDescription"] = "DESCRIPTION HERE",
    ["Commands"] = {
        ["COMMANDNAME"] = {
            ["ListName"] = "COMMANDNAME [ARGUMENT1]",
            ["Description"] = "DESCRIPTION HERE",
            ["Aliases"] = {"ALIAS1", "ALIAS2", "ALIAS3"},
            ["Function"] = function(args, speaker)
              -- CODE HERE  
            end
        }
     }
}

return Plugin
⚠️ **GitHub.com Fallback** ⚠️