# Check if a specific set of weapons is owned by the party

#### eomereolsson

##### Veteran
Well, one thing that definitely won't work are your examples 4 and 5. The function @caethyril provided tries to convert the notetag to a number and compares whether it is greater to or equal to 1. If you throw a text in there, that will obviously cause problems. If you want to compare the text of the notetag to some other text, try the following:
JavaScript:
``\$gameParty.members().some(function(actor) { return actor.weapons().some(function(item) { return item && item.meta && item.meta.Strenght.trim() == 'Strong'; }); });``
This will be true if any actor in the party has at least one weapon equipped with the notetag `<Strenght: Strong>`

Your other examples should work fine, theoretically. However I don't think you altered the statements in a way that actually accomplishes what you are trying to accomplish. (That is a bit hard to tell as you only told us how you altered them and that the do not work as intended, but didn't tell us what you intended). You altered the second argument that gets passed to `parseInt()`. This only alters to which number system the given text gets converted.
For example the content of the notetag <x: 101>, when passed through `parseInt(item.meta.x, 10)` would be the number 101 (1*100 + 0*10 + 1*1 or 1*10^2 + 0*10^1 + 1*10^0)in the decimal system (the normal number system that you are used to).
When passed through `parseInt(item.meta.x, 2)` it would still be the number 101, but in the binary system - or 5 in the decimal system(1*4 + 0*2 + 1*1 or 1*2^2 + 0*2^1 + 1*2^0).

I suspect you didn't want to alter how the notetag is converted to a number, but how that number in the notetag gets compared. That happens directly after that.
JavaScript:
``````//[...]
parseInt(item.meta.Strenght, 10) >= 1;
//[...]``````
If you want to check whether at least one actor in the party has a weapon with 5 Strenght or more, then you would replace the 1 with a 5.
If you want to change how both numbers are compared, you can change the operator for that, too. Instead of >= put:
- <= for less then or equal
- == for exactly equal

#### joket

##### Veteran
Ooh now I understand, completely skipped the Parse part, just copypasted blindlessly the code and was thinking it was just a check of meta cypher to cypher. Now I understand totally, thanks for helping!

#### caethyril

##### ^_^
JavaScript:
``\$gameParty.members().some(function(actor) { return actor.weapons().some(function(item) { return item && item.meta && item.meta.Strenght.trim() == 'Strong'; }); });``
By default the `meta` property is added to all note-bearing database items, so there shouldn't be a need to check for its existence. However, `item.meta.Strenght` might be a non-string value:
• `undefined` if that weapon does not have a `Strenght` notetag;
• `true` if that weapon has a tag with no value, e.g. `<Strenght>` rather than `<Strenght: 10>`.
In these cases there is no `trim` method available, which will cause an error. Instead, I'd consider something like this:

`\$gameParty.members().some(function(actor) { return actor.weapons().some(function(item) { return item && String(item.meta.Strenght || '').trim() === "Strong"; }); });`
I.e. convert to string first to avoid errors, then trim. (`String(undefined)` returns `"undefined"`, hence the `|| ''` just in case.)

[Edit: corrected `weapon` -> `item`.]

Last edited:

#### joket

##### Veteran
Nice suggestion, however it was working before, with the:

Code:
``\$gameParty.members().some(function(actor) { return actor.weapons().some(function(item) { return item && item.meta && item.meta.Strenght.trim() == 'Strong'; }); });``

While unfortunately it doesn't work with your:
Code:
``\$gameParty.members().some(function(actor) { return actor.weapons().some(function(weapon) { return item && String(item.meta.Strenght || '').trim() === "Strong"; }); });``

Notebox is:
<Strenght: Strong>

#### eomereolsson

##### Veteran
`undefined` if that weapon does not have a `Strenght` notetag;
That scenario I was trying to prevent. But somehow I wrote `... && item.meta && ...` instead of `... && item.meta.Strenght && ...`.
`true` if that weapon has a tag with no value, e.g. `<Strenght>` rather than `<Strenght: 10>`
And I completely forgot to catch that scenario

#### caethyril

##### ^_^
@joket: oops, I wrote `weapon` for the argument but `item` within the actual function. I edited my previous post with a correction, sorry~

#### joket

##### Veteran
Works perfectly thank you

### Latest Profile Posts

Not sure why I'm a jack of all trades , master of none... Sigh. Album out 06/03/2022 on all ur favorite platforms. 10 tracks.
Hmm... Mushrooms, maybe they're not poisonous...
Hi, I'm a new and upcoming Indie Developer, and I could really use some help when it comes to system programming. Explorers can only go so far before needing a map, you know?
I made a comic strip with the characters of my game.
Hey, what does it mean in settings, privacy, where it says allow users to: view your identities??????????