mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-21 21:52:07 +02:00
fixed timeout+smeltitem
This commit is contained in:
parent
663f7f9b1a
commit
48fd28a10f
2 changed files with 7 additions and 6 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue