MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / onCommand

Function onCommand

_datafiles/world/empty/rooms/tutorial/902.js:14–85  ·  view source on GitHub ↗
(cmd, rest, user, room)

Source from the content-addressed store, hash-verified

12
13// Generic Command Handler
14function onCommand(cmd, rest, user, room) {
15
16 ignoreCommand = false;
17
18 teacherMob = getTeacher(room);
19
20 // Make sure they are only doing stuff that's allowed.
21
22 if ( cmd == "south" && !canGoSouth ) {
23 teacherMob.Command("say Not so hasty! Lets finish up here before you leave the area.");
24 ignoreCommand = true;
25 }
26
27 fullCommand = ExpandCommand(cmd);
28 if ( rest.length > 0 ) {
29 fullCommand = cmd + ' ' + rest;
30 }
31
32 if ( teach_commands[commandNow] == fullCommand ) {
33
34 teacherMob.Command("say Good job!", 1.0);
35
36 if ( cmd == "equip stick" ) {
37 teacherMob.Command('say Check it out! If you type <ansi fg="command">status</ansi> you\'ll see the stick is equipped!', 1.0);
38 }
39
40 if ( cmd == "inventory" ) {
41 teacherMob.Command('say Hmm, it doesn\'t look like you\'re carrying much other than that sharp stick.', 1.0);
42 teacherMob.Command('say Remember, you can <ansi fg="command">look</ansi> at stuff you\'re carrying any time you want.', 1.0);
43 }
44
45 commandNow++;
46
47 if ( cmd == "attack dummy" ) {
48 return false;
49 }
50
51 } else {
52
53 if ( allowed_commands.includes(cmd) || teach_commands.slice(0, commandNow).includes(cmd) ) {
54 return false;
55 }
56
57 ignoreCommand = true;
58 }
59
60 switch (commandNow) {
61 case 0:
62
63 if ( !user.HasItemId(firstItemId) ) {
64 itm = CreateItem(firstItemId);
65 user.GiveItem(itm);
66 }
67
68 teacherMob.Command('say Go ahead and equip that sharp stick you\'ve got. Type <ansi fg="command">equip stick</ansi>.', 1.0);
69 break;
70 case 1:
71

Callers

nothing calls this directly

Calls 7

ExpandCommandFunction · 0.85
CreateItemFunction · 0.85
HasItemIdMethod · 0.80
GiveItemMethod · 0.80
getTeacherFunction · 0.70
getDummyFunction · 0.70
CommandMethod · 0.45

Tested by

no test coverage detected