mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-07-19 14:35:17 +02:00
Update tasks.js
This commit is contained in:
parent
188912537a
commit
35022f2a16
1 changed files with 9 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue