xLeeJYx Posted July 11, 2017 Report Share Posted July 11, 2017 (edited) With the code below, how do i make it return false if Not Usable In Crafting is found ? i couldnt make it to return true and false for this. Please help :c function craftable(item) { var descriptionLength = item.descriptions.length; for (i = 0; i < descriptionLength; i++) { if (item.descriptions[i].value === "( Not Usable in Crafting )") { return false } } return true } Edited July 11, 2017 by xLeeJYx Quote Link to comment Share on other sites More sharing options...
Vanilla Posted July 11, 2017 Report Share Posted July 11, 2017 (edited) With the code below, how do i make it return false if Not Usable In Crafting is found ? i couldnt make it to return true and false for this. Please help :c Those function should worksThis is how you call function craftable(item) offer.itemsToReceive.forEach(function(item) { if (craftable(item) == false){ //item is Not Usable in Crafting } else { //item is Usable in Crafting } }); //do same with itemToGive Edited July 11, 2017 by Vanilla Quote Link to comment Share on other sites More sharing options...
xLeeJYx Posted July 11, 2017 Author Report Share Posted July 11, 2017 Those function should worksThis is how you call function craftable(item) offer.itemsToReceive.forEach(function(item) { if (craftable(item) == false){ //item is Not Usable in Crafting } else { //item is Usable in Crafting } }); //do same with itemToGive im not doing that way :/ function isCraftWeapon(item) { function marketable(item) { if (item.marketable === true) { return false } } function Tags(item) { if (item.tags[1].name !== "Primary weapon" || item.tags[2].name !== "Secondary weapon" || item.tags[3].name !== "Melee weapon" || item.tags[4].name !== "Primary PDA" || item.tags[5].name !== "Secondary PDA") { return false } } function craftable(item) { var descriptionLength = item.descriptions.length; for (i = 0; i < descriptionLength; i++) { if (item.descriptions[i].value === "( Not Usable in Crafting )") { return false } } return true } var mkable = marketable(item) var ts = Tags(item) var cable = craftable(item) if (mkable === false || ts === false || cable === false) { return false } return true }Anything wrong with this code ? it seems to return everything as false Quote Link to comment Share on other sites More sharing options...
Vanilla Posted July 11, 2017 Report Share Posted July 11, 2017 (edited) Anything wrong with this code ? it seems to return everything as false Are you sure it's not this for the last line? if (mkable === false && ts === false && cable === false) { // && means [AND], || means [OR] return false } return true PS: I'm sorry if I got this wrong, I don't play TF2 Edited July 11, 2017 by Vanilla Quote Link to comment Share on other sites More sharing options...
xLeeJYx Posted July 11, 2017 Author Report Share Posted July 11, 2017 Are you sure it's not this for the last line? if (mkable === false && ts === false && cable === false) { // && means [AND], || means [OR] return false } return true PS: I'm sorry if I got this wrong, I don't play TF2 nope, if i use && all of them have to be false to return false. I used || because i want it to return false if any of them are false Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.