Add files via upload

This commit is contained in:
Lawtro37 2024-10-27 20:35:02 +10:00 committed by GitHub
parent e8e3cb7116
commit 648d4f8255
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 1 deletions

View file

@ -28,6 +28,8 @@ export class Agent {
initModes(this);
let last_death_pos = null;
let save_data = null;
if (load_mem) {
save_data = this.history.load();
@ -260,7 +262,21 @@ export class Agent {
this.bot.on('messagestr', async (message, _, jsonMsg) => {
if (jsonMsg.translate && jsonMsg.translate.startsWith('death') && message.startsWith(this.name)) {
console.log('Agent died: ', message);
this.handleMessage('system', `You died with the final message: '${message}'. Previous actions were stopped and you have respawned. Notify the user and perform any necessary actions.`);
let death_pos = this.bot.entity.position;
this.memory_bank.rememberPlace('last death position', death_pos);
let death_pos_text = null;
if (death_pos) {
death_pos_text = `x: ${death_pos.x.toFixed(2)}, y: ${death_pos.y.toFixed(2)}, z: ${death_pos.x.toFixed(2)}`;
}
let inventory = this.bot.inventory.slots;
let death_items = "";
for (let i=0; i<inventory.length; i++) {
if (inventory[i]) {
death_items += `${inventory[i].name} x${inventory[i].count}, `;
}
}
this.history.add('system', `You died at position ${death_pos_text || "unknown"} with the final message: '${message}'. Previous actions were stopped and you have respawned. Notify the user and perform any necessary actions.`);
this.handleMessage('system', `You died at position ${death_pos_text || "unknown"} and droped the items ${death_items} at your death position with the final message: '${message}'. Previous actions were stopped and you have respawned. Notify the user and perform any necessary actions. you can retrieve your items by doing the action !goToDeath.`);
}
});
this.bot.on('idle', () => {

View file

@ -295,6 +295,19 @@ export const actionsList = [
await skills.goToBed(agent.bot);
})
},
{
name: "!goToDeath",
description: "Go to the location of your bot's last death position and retrieve any lost items.",
perform: wrapExecution(async (agent) => {
let death_pos = agent.memory_bank.recallPlace('last death position')[0]; // <- dont even ask why this is an array
if (death_pos !== null) {
await skills.goToPosition(agent.bot, death_pos.x, death_pos.y, death_pos.z, 1);
console.log('going to death');
} else {
skills.log(agent.bot, "No death location saved.");
}
})
},
{
name: '!activate',
description: 'Activate the nearest object of a given type.',