2025-07-18 14:33:56 +00:00
|
|
|
function LookCommand(args, context) {
|
2021-11-04 21:19:50 +00:00
|
|
|
if (args.length == 1) {
|
2021-11-04 19:58:37 +00:00
|
|
|
context.examineRoom();
|
|
|
|
} else {
|
|
|
|
const room = context.getRoom(context.player.currentRoom);
|
|
|
|
const items = room.getItems();
|
|
|
|
let item = null;
|
|
|
|
for (let i of items) {
|
|
|
|
if (i.name.includes(args[1])) {
|
|
|
|
item = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-11-05 22:22:28 +00:00
|
|
|
if (!item) {
|
|
|
|
const items = context.player.getInventory();
|
|
|
|
for (let i of items) {
|
|
|
|
if (i.name.includes(args[1])) {
|
|
|
|
item = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-04 19:58:37 +00:00
|
|
|
if (!item) {
|
2021-11-05 13:28:01 +00:00
|
|
|
context.output.say(`I could not find a ${args[1]}.`);
|
2021-11-04 19:58:37 +00:00
|
|
|
} else {
|
2021-11-05 22:22:28 +00:00
|
|
|
context.output.say(`You look at ${item.name}.`);
|
2021-11-04 19:58:37 +00:00
|
|
|
context.output.say(item.description);
|
|
|
|
}
|
|
|
|
}
|
2025-07-18 14:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LookCommand.metadata = {
|
|
|
|
category: "Actions",
|
|
|
|
description: "Examine room or object",
|
|
|
|
arguments: [
|
|
|
|
{
|
|
|
|
type: "item",
|
|
|
|
name: "target",
|
|
|
|
optional: true,
|
|
|
|
description: "Object to examine"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
export default LookCommand;
|