From 5a2d3aee9bdf6894a6f3da3ab95b5a99ffa53fe3 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Mon, 27 Nov 2023 21:33:44 -0600 Subject: [PATCH] better log messages/example --- utils/examples.json | 2 +- utils/skills.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/utils/examples.json b/utils/examples.json index 8701255..60f41d2 100644 --- a/utils/examples.json +++ b/utils/examples.json @@ -19,7 +19,7 @@ ], [ - {"role": "user", "content": "hanky: collect some sand for me please"}, + {"role": "user", "content": "hanky: collect some sand and give it to me please"}, {"role": "assistant", "content": "Collecting sand...\n```\n// I am going to collect 3 sand and give to hanky.\nawait skills.collectBlock(bot, 'sand');\nawait skills.giveToPlayer(bot, 'sand', 'hanky');\n```"}, {"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."}, {"role": "assistant", "content": "Here!"} diff --git a/utils/skills.js b/utils/skills.js index 8842ee5..f3074dd 100644 --- a/utils/skills.js +++ b/utils/skills.js @@ -285,10 +285,14 @@ export async function giveToPlayer(bot, itemType, username) { * await skills.giveToPlayer(bot, "oak_log", "player1"); **/ let player = bot.players[username].entity - if (!player) + if (!player){ + log(bot, `Could not find ${username}.`); return false; - if (!getInventoryCounts(bot)[itemType]) + } + if (!getInventoryCounts(bot)[itemType]) { + log(bot, `You do not have any ${itemType} to give.`); return false; + } await goToPlayer(bot, username); let pos = player.position; await bot.lookAt(pos);