DoctorMcKay/node-tf2

false craftingComplete event

Closed this issue · 2 comments

I made a crafter to automatically break refined metal down.
`function craftChange() {
if (tf.backpack == undefined) {
console.log("CRAFT_ERROR: Cannot load backpack");
return
} else {
//setup
const metalIDs = [5000, 5001, 5002];
var metalIndex = [[],[],[]];

	//counts amount of metal in backpack, records positions
	for (var i = 0; i < tf.backpack.length; i++) {
		for (var n = 0; n < metalIDs.length; n++) {
			
			if (tf.backpack[i].def_index === metalIDs[n] && tf.backpack[i].origin != 1) {
				metalIndex[n].push(tf.backpack[i].id);
			}
		}
	}

	//determines whether crafting is needed
	console.log(metalIndex);
	for (var i = 0; i < metalIndex.length; i++) {
		if (metalIndex[i].length < 4 && i < 2) { //smelts metal
			//tf.craft(metalIndex[i+1],23);
			//console.log('Smelted metal. ' + metalIDs[i+1]);
		} else if (metalIndex[i].length > 6 && i < 2) {
			tf.craft(metalIndex[i]);
			console.log('Combined metal.' + metalIDs[i]);
		}
	}

}

}`
At it's current state, it should try to craft 1 refined metal.
The craftingComplete event gets emitted, and nothing has happened.
Even if I close the bot to 'reset' the inventory, nothing has happened.
How do I fix this?

whoops! I figured out that craftingComplete emitted a -1. Still need help finding why...

You must pass exactly three item IDs to craft() in order to combine metal. You can't do more than one batch at a time.