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?
If player have Item (Variables X)
RPG Maker MV Supportyou 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
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
You can reference item ID X, where X is the value of game variable 1, like this:
Replace the
There are a few relevant native methods available:
So here's a couple of examples for use in Conditional Branch > Script:
[Edit: added
JavaScript:
$dataItems[$gameVariables.value(1)]
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
[Edit: added
isAnyMemberEquipped to method list.]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 🙂
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 🙂
Oh, Thank you!
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.
Here you have all the scripts you can call by the engine
ALL SCRIPT CALL
This wasnt created by me.
Original thread: https://forums.rpgmakerweb.com/threads/if-player-have-item-variables-x.123031/