Jump to content
McKay Development

Recommended Posts

Posted

I have a question about where should i put my crafting recipe in the code

 

My code

//Show Online
client.on('loggedOn', function (details) {
    console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID());
	client.setPersona(1);
});

//crafting
tf2.on("backpackLoaded", function(craft) {
	manager.getInventoryContents(440, 2, true, function (err, inventory){
		if (err) {
			console.log(err);
		} else {
			var scrap = inventory.filter(function (item) {
				return item.name == "Scrap Metal"
			});
			var reclaimed = inventory.filter(function (item) {
				return item.name == "Reclaimed Metal"
			});
			var refined = inventory.filter(function (item) {
				return item.name == "Refined Metal"
			});
			
			if (refined.length < 1){
				console.log("NO REF");
				for (let i = 0; i < reclaimed.length; i++) {
					tf2.craft([reclaimed[i].id]); //where should i put my recipe in?
				}
			}
		}
	});
})
https://dev.doctormckay.com/topic/1416-tf2-crafting-recipe/?hl=recipe

I tried this code, yes it crafted me some metals, but i want refined metal while it gave me scrap from reclaimed metals. So how can i change my recipe in order to get what i needed?

 

Btw Happy New Year McKay

Posted (edited)

You need to pass craft an array of item IDs you want to craft together. Right now you're just passing in one metal per craft, so it's smelting the metal down because that's all it can do with one metal.

How can i put them together?

                            console.log("NO REF");
				for (let i = 0; i < scrap.length; i++) {
					var array = [scrap.id, scrap.id, scrap.id]
					tf2.craft(array);
				}
Edited by TextDynasty
Posted

I have a question about where should i put my crafting recipe in the code

 

My code

//Show Online
client.on('loggedOn', function (details) {
    console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID());
	client.setPersona(1);
});

//crafting
tf2.on("backpackLoaded", function(craft) {
	manager.getInventoryContents(440, 2, true, function (err, inventory){
		if (err) {
			console.log(err);
		} else {
			var scrap = inventory.filter(function (item) {
				return item.name == "Scrap Metal"
			});
			var reclaimed = inventory.filter(function (item) {
				return item.name == "Reclaimed Metal"
			});
			var refined = inventory.filter(function (item) {
				return item.name == "Refined Metal"
			});
			
			if (refined.length < 1){
				console.log("NO REF");
				for (let i = 0; i < reclaimed.length; i++) {
					tf2.craft([reclaimed[i].id]); //where should i put my recipe in?
				}
			}
		}
	});
})
https://dev.doctormckay.com/topic/1416-tf2-crafting-recipe/?hl=recipe

I tried this code, yes it crafted me some metals, but i want refined metal while it gave me scrap from reclaimed metals. So how can i change my recipe in order to get what i needed?

 

Btw Happy New Year McKay

https://github.com/xLeeJYx/TF2-Crafting-Recipe/blob/master/craftRecipe.json

 

Follow that, and btw you have to craft scrap to reclaimed, then reclaimed to refined. You cant go x9 scrap immediately to refined

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...