| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This module allows you to
-- get madatory module operators
VFS.Include("modules.lua") -- modules table
VFS.Include(modules.attach.data.path .. modules.attach.data.head) -- attach lib module
-- get other madatory dependencies
attach.Module(modules, "message") -- communication backend load
attach.Module(modules, "customCommands") -- this module load
Widget developers just care about using this code, because it is up to game developer to provide all dependencies
sendCustomMessage.RegisterCustomCommand({
type = CMDTYPE.ICON_MAP,
name = 'Convoy',
cursor = 'Attack',
action = 'Convoy',
tooltip = 'Some convoy behavior',
hidden = false,
UIoverride = { texture = 'LuaUI/Images/commands/bold/sprint.png' },
whitelist = {armpw} -- optional
-- there are also some optional items, check more in example widget
})
As key we use for mapping we take string you sent as name in a command definition, e.g. name = 'Convoy',
local rawCustomCommandsList = Spring.GetTeamRulesParam(Spring.GetMyTeamID(), "CustomCommandsNameToID") if (rawCustomCommandsList ~= nil) then local fullMapping = message.Decode(rawCustomCommandsList) end
But you can just check notification messages (containing only name and id of the newly registered command) which you access next way:
-- EVENT HANDLING SYSTEM EXAMPLE
function CustomCommandRegistered(cmdName, cmdID)
Spring.Echo("Command [" .. cmdName .. "] was registered under ID [" .. cmdID .. "]")
end
function widget:Initialize ()
widgetHandler:RegisterGlobal('CustomCommandRegistered', CustomCommandRegistered)
end
Happens via just sending the name of the command you want to deregister
sendCustomMessage.DeregisterCustomCommand(cmdDesc.name)
Happens same as registration
| Back | FazBrowse Home | New Git URL |