MoreOutput / RockMUD

Node Websocket MUD Server. Demo: https://rockmud.herokuapp.com/
MIT License
157 stars 43 forks source link

Making commands that take multiple arguments #104

Closed UnbanTwin closed 8 years ago

MoreOutput commented 8 years ago

Provide an example of what you're aiming to do please.

UnbanTwin commented 8 years ago

I am trying to make a command that allows player to transfer gold to each other, so lets say the command looks like this:

transfer [amount] [player]

How do I get the second argument, would I do command.arg[1]

MoreOutput commented 8 years ago

Hoping to get back to you on everything sometime today (Friday).

Just seeing this response; so the command object passed into each command looks like:

{ cmd: '', // {cast} spark boar msg: '', // cast {spark boar} arg: '', // cast {spark} boar input: '', // cast spark {boar ...} number: 1, // augment target -- cast spark 2.boar roomObj: roomObj // optional -- allows for commands to skip redundant room lookup }

As such the 'player' name, your third word, would be on command.input. This next commit will implement the 'give' command which will cover this case.