better log messages/example

This commit is contained in:
MaxRobinsonTheGreat 2023-11-27 21:33:44 -06:00
parent af980a3df8
commit 5a2d3aee9b
2 changed files with 7 additions and 3 deletions

View file

@ -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!"}

View file

@ -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);