From 35022f2a16a1b2fb566ef26e29317b6bdefa8785 Mon Sep 17 00:00:00 2001 From: Sweaterdog Date: Thu, 27 Feb 2025 21:21:32 -0800 Subject: [PATCH] Update tasks.js --- src/agent/tasks.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/agent/tasks.js b/src/agent/tasks.js index a51bb0c..7057f6a 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks.js @@ -36,7 +36,6 @@ export class TaskValidator { } } - export class Task { constructor(agent, task_path, task_id) { this.agent = agent; @@ -50,7 +49,11 @@ export class Task { this.taskTimeout = this.data.timeout || 300; this.taskStartTime = Date.now(); this.validator = new TaskValidator(this.data, this.agent); - this.blocked_actions = this.data.blocked_actions || []; + if (this.data.blocked_actions) { + this.blocked_actions = this.data.blocked_actions[this.agent.count_id.toString()] || []; + } else { + this.blocked_actions = []; + } this.restrict_to_inventory = !!this.data.restrict_to_inventory; if (this.data.goal) this.blocked_actions.push('!endGoal'); @@ -81,11 +84,6 @@ export class Task { isDone() { if (this.validator && this.validator.validate()) return {"message": 'Task successful', "code": 2}; - // TODO check for other terminal conditions - // if (this.task.goal && !this.self_prompter.on) - // return {"message": 'Agent ended goal', "code": 3}; - // if (this.task.conversation && !inConversation()) - // return {"message": 'Agent ended conversation', "code": 3}; if (this.taskTimeout) { const elapsedTime = (Date.now() - this.taskStartTime) / 1000; if (elapsedTime >= this.taskTimeout) { @@ -105,6 +103,10 @@ export class Task { bot.chat(`/clear ${name}`); console.log(`Cleared ${name}'s inventory.`); + //kill all drops + if (this.agent.count_id === 0) { + bot.chat(`/kill @e[type=item]`); + } //wait for a bit so inventory is cleared await new Promise((resolve) => setTimeout(resolve, 500)); let initial_inventory = null;