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
164
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
164
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
212
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 Profile Posts

Ahh, end of the day stinky feet, fresh out of the boots. Smells like a job well done. Seriously, I have to rinse my feet when I get home, or it's not fair to my wife.
Stream will be live shortly with some pixel art! Feel free to drop by!

Can't believe I forgot to put an image of my drawing pad! It looks kinda like this, maybe I'll get a better pic tomorrow...
Backup tip: If you don't want to back up your whole project every day, at least back up everything *except* your Image and Audio folders, which you can do weekly/as needed/etc.
The final version of our game is already available both in English and Spanish! ^___^
Can't believe this day has finally come... T_T

Forum statistics

Threads
97,824
Messages
947,187
Members
129,037
Latest member
Luciamandela
Top