Skip to content

Server command line API #14

@ArthurCose

Description

@ArthurCose

There's a need for two command interfaces, one from the client, and one from stdin. A command from the server would not have a player_id.

Net:on("command", function(event)
  -- { player_id: string?, command: string }
  print(event.player_id, event.command)
end)

Responding to the client would require a new function or a set of new functions. We have print, warn, and printerr for stdout, it may make sense to have Net equivalents such as Net.print(player_id, ...) with nil player_id resolving to stdout instead of sending a packet.

Net:on("command", function(event)
  if not event.command:find("^/echo ") then
    return
  end

  local message = event.command:sub(7)
  Net.print(event.player_id, message)
end)

The command listener above would respond to /echo hello with hello to the player or cli depending on where the command was entered.
A simple chat could be implemented by running Net.print over every player if the message does not start with a /. The scripter could decide if the chat would be per area or server wide as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions