How do I check if an item is a key item? I've been searching through the .js files, but I can't seem to find anything.
Checking if item is key..
Learning JavascriptI'm guessing that there would have to be a property in $dataItems that stores which type it is. Create a couple of blank items of different types (Normal vs Key) and then console.log() $dataItems. See if you can find the property that signifies this.
The property is:
$dataItems[itemId].itypeId
It's a key item when the value is 2.
What's the context? How are you choosing which item to examine? How you'd find/compare this might change depending on the context.
$dataItems[itemId].itypeId
It's a key item when the value is 2.
What's the context? How are you choosing which item to examine? How you'd find/compare this might change depending on the context.
I was just looking for a way to count the number of non-key non-equipment items.
After a lot of experimentation, I came up with this:
It's probably more complicated than it needs to be, but I couldn't figure out any other way to do it.
EDIT: WHOOPS! Above counts key items. Try the following to count non-key items, including hidden items.
Or this to count only regular items
Code:
$gameParty.items().filter(function(element){return element.itypeId == 2;}).reduce(function(total, element){return total + $gameParty._items[element.id]},0)
It's probably more complicated than it needs to be, but I couldn't figure out any other way to do it.
EDIT: WHOOPS! Above counts key items. Try the following to count non-key items, including hidden items.
Code:
$gameParty.items().filter(function(element){return element.itypeId != 2;}).reduce(function(total, element){return total + $gameParty._items[element.id]},0)
Or this to count only regular items
Code:
$gameParty.items().filter(function(element){return element.itypeId == 1;}).reduce(function(total, element){return total + $gameParty._items[element.id]},0)
Original thread: https://forums.rpgmakerweb.com/threads/checking-if-item-is-key.89754/