If player have Item (Variables X)

OngkrubG

Villager
Member
Joined
Aug 24, 2014
Messages
6
Reaction score
1
First Language
Thai
Primarily Uses
RMMV
I want the Conditional Branch to check if player has itemID X (Replace X with a Variable) but I don't want to use Script in Event's last place, I want to use the Script Section in Conditional Branch. What should I write down?
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,948
Reaction score
1,053
First Language
Dutch
Primarily Uses
RMMV
you dont need a scriptcall, but its possible.

if: party has x item (replace x with item ID) its on the 4th tab in contianl brance
do stuff
else
do stuff if party dont have the item
end

you can also create a variable and be that item BEFORE the conditional brance

control variable x -> gamedata -> item (x being the variable ID)

than:

if: variable x >= 3 (var ID you use for data items) when player has 3 of the items
do stuff
else
do stuff if its below 3
end

this is the basic without any scriptcalls
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
You can reference item ID X, where X is the value of game variable 1, like this:
JavaScript:
$dataItems[$gameVariables.value(1)]
Replace the 1 with your variable ID. For Weapon or Armor items, replace $dataItems with $dataWeapons or $dataArmors respectively.

There are a few relevant native methods available:
  • $gameParty.hasItem(item, includeEquips)
    True iff the party has at least one of the specified item, optionally including equipped items.
  • $gameParty.numItems(item)
    Counts the number of the specified item currently in the inventory...does not include equips!
  • $gameParty.isAnyMemberEquipped(item)
    True iff at least one party member has the specified item equipped.

So here's a couple of examples for use in Conditional Branch > Script:
  • True if at least one of item ID X either in inventory or equipped by a party member:
    JavaScript:
    $gameParty.hasItem($dataItems[$gameVariables.value(1)], true)
  • True if inventory contains at least 5 of item ID X:
    JavaScript:
    $gameParty.numItems($dataItems[$gameVariables.value(1)]) >= 5
:kaophew:

[Edit: added isAnyMemberEquipped to method list.]
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,948
Reaction score
1,053
First Language
Dutch
Primarily Uses
RMMV
I didn't know the 2nd part of the scriptcall, I save that to remember :)

to make that above simplier if you need to do over 50+ of those,
check out this plugin "ConditionalBranch+" which can make your conditions
way shorter and cleaner.

in case you only need 3-10 max, use the methode caethyril suggested :)
 

OngkrubG

Villager
Member
Joined
Aug 24, 2014
Messages
6
Reaction score
1
First Language
Thai
Primarily Uses
RMMV
You can reference item ID X, where X is the value of game variable 1, like this:
JavaScript:
$dataItems[$gameVariables.value(1)]
Replace the 1 with your variable ID. For Weapon or Armor items, replace $dataItems with $dataWeapons or $dataArmors respectively.

There are a few relevant native methods available:
  • $gameParty.hasItem(item, includeEquips)
    True iff the party has at least one of the specified item, optionally including equipped items.
  • $gameParty.numItems(item)
    Counts the number of the specified item currently in the inventory...does not include equips!
  • $gameParty.isAnyMemberEquipped(item)
    True iff at least one party member has the specified item equipped.

So here's a couple of examples for use in Conditional Branch > Script:
  • True if at least one of item ID X either in inventory or equipped by a party member:
    JavaScript:
    $gameParty.hasItem($dataItems[$gameVariables.value(1)], true)
  • True if inventory contains at least 5 of item ID X:
    JavaScript:
    $gameParty.numItems($dataItems[$gameVariables.value(1)]) >= 5
:kaophew:

[Edit: added isAnyMemberEquipped to method list.]
Oh, Thank you! This is vital system in my game and for this, I will put your name on extra credit and if I translate my game to English(or you can read Thai) I will send it to you!
 

MightyEgg

Veteran
Veteran
Joined
Mar 20, 2020
Messages
60
Reaction score
10
First Language
Portuguese
Primarily Uses
RMMV
If you need to call script
Here you have all the scripts you can call by the engine
ALL SCRIPT CALL
This wasnt created by me.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,539
Members
137,834
Latest member
EverNoir
Top