Checking item cost and other things

Psyche Radio

PsyRad
Member
Joined
Apr 21, 2019
Messages
8
Reaction score
1
First Language
Hungarian
Primarily Uses
RMMV
Hi, semi-lurker here.
For a while I've been struggling to make a small bargain system where in battle you could use a "tribute" skill to trade any item and depending on it's value, the enemy would abort battle and leave you alone. However, for that I'd need to check the price of the items, as well as if the party has any (regular) items in the first place and so far I've found no way to actually check those values.
:kaoswt2:

Are there any script calls or the likes to check those two values? Don't really want to abandon this game mechanic.
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
167
First Language
English
Primarily Uses
RMMV
The data of items are stored in three arrays, these are:
$dataItems
$dataWeapons
$dataArmors

The price of let's say, item 5, is stored in $dataItems[5].price

The [5] is the item ID, so if it is armor 11 it would be $dataArmors[11].price

So if you want to do a conditional branch you can do it with that variable with the regular checks. Like $dataItems[5].price < 100

You can also set a game variable to an items price by using Control Variables, the operand Script and simply entering $dataItems[5].price

I'm guessing you're asking how to check if the party has any regular items at all, correct me if I'm wrong.
Then this returns true if the party has items in the inventory: Object.keys($gameParty._items).length > 0

Maybe this helps :rock-right:
 
Last edited:

Psyche Radio

PsyRad
Member
Joined
Apr 21, 2019
Messages
8
Reaction score
1
First Language
Hungarian
Primarily Uses
RMMV
Ah! Thanks, $dataItems[var].price did work. :kaophew:

Also yeh, that's what I mean. But the code didn't work. :v
I need it specifically to be regular items, and regular items only because the skill still shows up when I have any other item with me. (though I am also using Yanfly's Skillcore so its most likely me just not understanding how to use the plugin)
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
167
First Language
English
Primarily Uses
RMMV
That's odd, Object.keys($gameParty._items).length > 0 works for me, and it's for regular items. Are you using it in a conditional branch?
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
394
Reaction score
213
First Language
English
Primarily Uses
RMMV
I'm assuming you mean regular items as in the selection between regular item/hidden item/key item etc. If so you could use something like this:

Code:
$gameParty.items().filter(function(item) {return item.itypeId === 1}).length > 0
 

Psyche Radio

PsyRad
Member
Joined
Apr 21, 2019
Messages
8
Reaction score
1
First Language
Hungarian
Primarily Uses
RMMV
@ozubon I am using scripts inside a notetag.

@Silva Thanks, that worked! And yeah I did mean that.
 

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

Latest Threads

Latest Posts

Latest Profile Posts


:3c here's a thing i made a while while while back
Tried mochi for the first time. It's quite nice. Has a pleasant smell and taste, and is nice and chewy.
made a bio for the protag in my project!
Beggar : "I haven't eat for days..."
Kid : "Just do crime! You will get daily necessity for free in prison~"

Forum statistics

Threads
99,159
Messages
962,454
Members
130,725
Latest member
teendinsaikha
Top