Add some sound functionality

This commit is contained in:
2021-11-05 14:28:01 +01:00
parent dd066f0aa3
commit c5a4167846
32 changed files with 187 additions and 30 deletions

View File

@@ -3,6 +3,6 @@ export default function EchoCommand(args, context) {
context.print(`Usage: echo <on/off>`);
} else {
context.setInputEcho(args[1] == "on" ? true : false);
context.print(`Command echo is now ${args[1]}`);
context.print(`Command echo is now ${args[1]}.`);
}
}

View File

@@ -12,7 +12,7 @@ export default function LookCommand(args, context) {
}
}
if (!item) {
context.output.say(`I could not find a ${args[1]}`);
context.output.say(`I could not find a ${args[1]}.`);
} else {
context.output.say(item.name);
context.output.say(item.description);

View File

@@ -9,14 +9,14 @@ export default function TakeCommand(args, context) {
}
}
if (!item) {
context.print(`You can't find any ${args[1]}`);
context.print(`You can't find any ${args[1]}.`);
} else {
if (!item.takeable) {
context.print(`You can't take ${item.name}`);
context.print(`You can't take ${item.name}.`);
} else {
room.removeItem(item.id);
context.player.addItem(item.id);
context.print(`You take ${item.name}`);
context.print(`You take ${item.name}.`);
item.onTake();
}
}

View File

@@ -9,7 +9,16 @@ export default async function UseCommand(args, context) {
}
}
if (!item) {
context.output.say(`I could not find a ${args[1]}`);
const items = context.player.getInventory();
for (let i of items) {
if (i.name.includes(args[1])) {
item = i;
break;
}
}
}
if (!item) {
context.output.say(`I could not find a ${args[1]}.`);
} else {
await item.onUse();
}