2025-07-18 18:41:49 +00:00
|
|
|
import CommandBuilder from "../builders/command";
|
|
|
|
|
|
|
|
function dropHandler(args, context) {
|
2022-10-26 14:45:32 +00:00
|
|
|
const room = context.getRoom(context.player.currentRoom);
|
|
|
|
const items = context.player.getInventory();
|
|
|
|
let item = null;
|
|
|
|
for (let i of items) {
|
|
|
|
if (i.name.includes(args[1])) {
|
|
|
|
item = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!item) {
|
|
|
|
context.print(`You're not carrying a ${args[1]}`);
|
|
|
|
} else {
|
2024-03-22 17:23:46 +00:00
|
|
|
context.player.removeItem(item.getID());
|
|
|
|
room.addItem(item.getID());
|
2022-10-26 14:45:32 +00:00
|
|
|
context.print(`You set ${item.name} down on the floor.`);
|
|
|
|
item.onDrop();
|
2025-07-18 14:33:56 +00:00
|
|
|
|
|
|
|
// Refresh mobile commands when items change
|
|
|
|
context.commandHandler.refreshMobileCommands();
|
2022-10-26 14:45:32 +00:00
|
|
|
}
|
2025-07-18 14:33:56 +00:00
|
|
|
}
|
|
|
|
|
2025-07-18 18:41:49 +00:00
|
|
|
export default new CommandBuilder()
|
|
|
|
.withName("drop")
|
|
|
|
.withAliases(["put"])
|
|
|
|
.withCategory("Actions")
|
|
|
|
.withDescription("Drop an object")
|
|
|
|
.withArgument("item", "target", false, "Object to drop")
|
|
|
|
.withHandler(dropHandler)
|
|
|
|
.create();
|