need help to write this: Conditional if item(2) OR item(3) >=0 then

256.png
257.png


Hello 🙂 Im trying out some script conditionals and cant seem to get this one correct. Tried some variations I found on ScriptCall list and in forums.

Is it valid to write
"$gameParty.hasItem(94) OR $gameParty.hasItem(95) OR $gameParty.hasItem(14) >= 0"

(if has bigger than zero of 94,95,14)

I want 1 conditional to check if has item 94, OR 95, OR 96, OR 97, OR 98, OR 99, OR 100, OR 101.
These are "mana type items" and im having a picture displayed if hero carry any of these.

Today im controlling it with a very long and "clumsy" conditional if item else event, so this is something I wanted to try to get a bit more sane common event.

thx 😀
OR is || in js as far as I know. Idk if OR works too...
In the 2nd screenshot, you can do it seperately. $gameParty.hasItem($dataItems[94]) >=0 || $gameParty.hasItem($dataItems[95]) >=0
I think this is more accurate...


Edit! If you want to check if it's greater than zero, then you should remove the = from >=
Ah thanks Hyouryuu-Na! Much help 😍
$gameParty.hasItem(id) returns a true or false value, so you don't compare it to 0. If they have one or more of the item, it returns true, if they don't have any, it returns false.

Why are you doing >= 0? Do you want to see if they have a specific number, or just if they have at least one? If the latter, $gameParty.hasItem(95) || $gameParty.hasItem(14) is all you need to enter.
:") Ahh I see. I never looked at the item script calls before. Thanks @Shaz
Actually that's not right either. The function takes an item, not an item id. And an item could be an item, a weapon, or armor. It also takes a flag to indicate whether it includes equipped stuff.

So if 14 and 95 are actual items, in the Items tab of the database, your call should be this:
Code:
$gameParty.hasItem($dataItems[14]) || $gameParty.hasItem($dataItems[95])

If item 14 is a weapon and item 95 is armor, and you want to include equipped stuff, then the call would be this:
Code:
$gameParty.hasItem($dataWeapons[14], true) || $gameParty.hasItem($dataArmors[95], true)


Just read the rest of your opening post. To see if the party has any of those items, the call would be:
Code:
[94, 95, 96, 97, 98, 99, 100, 101].some(function(id) { return $gameParty.hasItem($dataItems[id]); });
Thank you Shaz! This is my first time doing item operations, so this is real nice to know! thx!
Just for info, this is fairly easy to do without scripting, e.g. just use multiple branches to check for multiple items:
Code:
◆Control Switches:#0001 HasItem = OFF
◆If:Party has Potion
  ◆Control Switches:#0001 HasItem = ON
  ◆
:End
◆If:Party has Super Potion
  ◆Control Switches:#0001 HasItem = ON
  ◆
:End
◆If:HasItem is ON
  ◆Text:None, Window, Bottom
  :    :Yes, that potion will do!
  ◆
:Else
  ◆Text:None, Window, Bottom
  :    :You have no potions.
  ◆
:End

Original thread: https://forums.rpgmakerweb.com/threads/need-help-to-write-this-conditional-if-item-2-or-item-3-0-then.112374/