Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat command registration for tools #31

Open
S-S-X opened this issue Jun 19, 2020 · 0 comments
Open

Chat command registration for tools #31

S-S-X opened this issue Jun 19, 2020 · 0 comments
Labels
API Metatool API issues enhancement New feature or request

Comments

@S-S-X
Copy link
Owner

S-S-X commented Jun 19, 2020

Allow registering custom chat commands for tools through MetaTool API.

There's already basic chat command API available (https://github.com/S-S-X/metatool/blob/master/metatool/command.lua) but currently it only implements single command /metatool:give which is automatically applied for administrative tools that require some predefined privileges (https://github.com/S-S-X/metatool/blob/master/metatool/api.lua#L91).

Extend this API to allow registering custom chat commands for tools, for example

local mytool = metatool:register_tool("mytool", {
  do_apocalypse = function(style) {
    if style == nil or style == "local" then
      -- here we should start just small and simple apocalypse, maybe only destroy earth or moon?
    elseif style == "global" then
      -- here we should probably loop through players, maybe kill them all and then start replacing air with lava
    else
      -- invalid apocalypse style given
    end
  }
  ... other stuff required for tool registration goes around here ...
}

-- Chat command registration:
mytool:register_command(
  "apocalypse",
  "Initiates apocalypse, usage:\n/${cmd} [local|global]",
  "do_apocalypse"
)

Above should then add chat command /mytool:apocalypse that parses arguments and calls defined method do_apocalypse.

Some frames and same format for all registered commands with automated argument parsing / forwarding for predefined tool method.
Probably keep it simple and straightforward other than above preprocessing. Actual tool definition method should still be responsible for actual functionality and argument checks.

Possible extra arguments for registration method:

  • Required privileges?

Possible extra arguments for callback method:

  • Include coordinates / position?
  • Include pointed node and coords for that node?
@S-S-X S-S-X added enhancement New feature or request API Metatool API issues labels Jun 19, 2020
@S-S-X S-S-X self-assigned this Jul 8, 2020
@S-S-X S-S-X removed their assignment Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Metatool API issues enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant