-
Notifications
You must be signed in to change notification settings - Fork 42
Implementing A New Command
Rocky Bevins edited this page Aug 9, 2020
·
20 revisions
Lets add a 'report' command that will give the command issuer's current HP to their current Room.
First add new file 'report.js' to src/commands (note that new commands can be added directly into commands.js).
'use strict'
var World = require('../world');
module.exports = function(entity, command) {
World.msgRoom(command.roomObj, {
msg: 'Current HP: ' + entity.chp
});
};
Now when you restart the server you can expect a 'report' command to give every player in the room the callers current HP.
If you wanted a player facing alias for our new report command (for example 'rep') you can expand the logic in your client file. RockMUDs public/js/rockmud-client.js serves as an example.