Item Class Property

Is there a way to give new properties to the Item class itself. For example, in RGSS3, you have:

class RPG::Item def phoenix_down;endendHow can you do this in MV's JS? In my understanding, this is for me to do properties and call those properties after. For example:

Code:
	if (DataManager.isItem(item) && item.phoenix_down) {		//stuff here	}
in MV ... there's no RPG::Item equivalent...

we can access the data from $dataItems though...

you can create outside function that pass those item object from $dataItems.

for example inside Game_System (so it can be called anywhere using $gameSystem

example:

Game_System.prototype.phoenix_down = function(item) {    comment = item.note;    if(comment.match(/<phoenix_down>/im)) return true;    return false;};
to use it... you can use this anywhere:

if (DataManager.isItem(item) && $gameSystem.phoenix_down(item)) {        //stuff here}hope this help.
How about something like this in particular?

class RPG::Item def volume_of_power return (self.note[/\\maximum([0-9]+?)/] ? [$1.to_i, 1].max : 1) end def percentage_of_power return (self.note[/\\power([0-9]+?)%/] ? [$1.to_i, 1].max : 100) endendWhat is its direct translation?
maybe...

Game_System.prototype.volume_of_power = function(item) {    var value = 1;    var comment = item.note;    if(comment.match(/\\maximum([0-9]+?)/im)) var vol = Number(comment.match(/\\maximum([0-9]+?)/i)[1]);    if (vol) value = Math.max(value, vol);    return value;};Game_System.prototype.percentage_of_power = function(item) {    var value = 100;    var comment = item.note;    if(comment.match(/\\power([0-9]+?)%/im)) value = Number(comment.match(/\\power([0-9]+?)%/i)[1]);    value = Math.max(value, 1);    return value;};
didn't test it though. i also use your regexp. but i think it should work fine if ACE version regexp works fine.
what I would do:

$dataItems.forEach(item) { if (item !== null && item.name === 'some name here') { //do some code }}We check if item is null because if you look at $dataItems, the first on seems to be null  ...
what I would do:

$dataItems.forEach(item) { if (item !== null && item.name === 'some name here') { //do some code }}We check if item is null because if you look at $dataItems, the first on seems to be null  ...
all array in MV is mostly like that... it's because MV insert array[1] as his first data[1] in database.... so $dataItems[1] will means item 1 in database.

BUT... in JS... adding index [1]... will automatically set the index [0] as null.

Hudell encounter that behavior in his Orange Custom Event. he add new event to index 1000 +.

which then automatically insert null to all index before 1000... thus making it lag (20-30 fps loss) when there's some code that iterate $gameMap._events.length

beware all new JS scripter (which converted from our nice and easygoing ruby) for this issues...
all array in MV is mostly like that... it's because MV insert array[1] as his first data[1] in database.... so $dataItems[1] will means item 1 in database.

BUT... in JS... adding index [1]... will automatically set the index [0] as null.
thanks for spitting out the obvious ... LOL
thanks for spitting out the obvious ... LOL
sorry no offense. but not everyone know this 😀 . just wanna share...

even Hudell which have write lots of great plugin got caught by this...

the problem lies with array method .length...

even you only have 1 data. but because there's a null in index before that data. the length is not 1 anymore. but 2.

ex:

var a = [];a[1000] = "this is a txt";console.log(a.length);it will print 1001 althouth the actual data is only 1.

thus that's why the first $data object in MV will always null. i just want to explain that.

Original thread: https://forums.rpgmakerweb.com/threads/item-class-property.49428/