diff --git a/utils/coder.js b/utils/coder.js index 5ea4341..61f3211 100644 --- a/utils/coder.js +++ b/utils/coder.js @@ -83,7 +83,7 @@ export class Coder { console.error('Error writing code execution file: ' + result); return {success: false, message: result, interrupted: false, timedout: false}; } - + let TIMEOUT; try { console.log('executing code...\n'); let execution_file = await import('.'+filename); @@ -91,10 +91,10 @@ export class Coder { this.current_code = this.queued_code; this.executing = true; - const TIMEOUT = this._startTimeout(10); + TIMEOUT = this._startTimeout(1); await execution_file.main(this.agent.bot); // open fire - clearTimeout(TIMEOUT); this.executing = false; + clearTimeout(TIMEOUT); this.agent.bot.emit('finished_executing'); let output = this.formatOutput(this.agent.bot); @@ -104,8 +104,10 @@ export class Coder { return {success:true, message: output, interrupted, timedout}; } catch (err) { this.executing = false; + clearTimeout(TIMEOUT); + this.agent.bot.emit('finished_executing'); - console.error("Code execution triggered catch:" + err); + console.error("Code execution triggered catch: " + err); let message = this.formatOutput(this.agent.bot); message += '!!Code threw exception!! Error: ' + err; let interrupted = this.agent.bot.interrupt_code; diff --git a/utils/skills.js b/utils/skills.js index 9d97a0d..2b119bc 100644 --- a/utils/skills.js +++ b/utils/skills.js @@ -57,13 +57,12 @@ export async function smeltItem(bot, itemName, num=1) { let furnaceBlock = undefined; furnaceBlock = getNearestBlock(bot, 'furnace', 6); - if (furnaceBlock === null){ + if (!furnaceBlock){ log(bot, `There is no furnace nearby.`) return false; } await bot.lookAt(furnaceBlock.position); - console.log('smelting...'); const furnace = await bot.openFurnace(furnaceBlock); // check if the furnace is already smelting something