Jump to content
McKay Development

Check for uncraft


xLeeJYx

Recommended Posts

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 by xLeeJYx
Link to comment
Share on other sites

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 works

This 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 by Vanilla
Link to comment
Share on other sites

 

Those function should works

This 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

Link to comment
Share on other sites

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 by Vanilla
Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

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...