Status
Not open for further replies.

Hellinfernel

Veteran
Veteran
Joined
Jun 26, 2022
Messages
53
Reaction score
7
First Language
German
Primarily Uses
RMMZ
Currently, I am experimenting with JS notetags and I try to figure out which one I need to do the thing I want to do. I have an item which has no effects directly in the RPG maker engine, but is supposed to have effects inside a JS notetag, so I have full control over what's happening.
Code:
<JS Post-Apply>
console.log($dataItems[this.itemId()].meta.TpCost);
target.gainTp((parseInt($dataItems[this.itemId()].meta.TpCost)) * -1);
target.gainMp(parseInt($dataItems[this.itemId()].meta.MpRegen));
target.gainHp(parseInt($dataItems[this.itemId()].meta.HpRegen));
target.gainExp(parseInt($dataItems[this.itemId()].meta.ExpGain));
</JS Post-Apply>
Trust me, it's supposed to be that way.

Now, this code is supposed to be inherited by other items using the Database Inheritance VisuStella MZ plugin. That way, I can keep the code for all items of that kind the same, which reduces maintenance. The problem is now that, no matter what I do, simply nothing happens, and I have no idea why. The only thing i can imagine is that the code gets never called in the first place.

So my question is:

- What is the correct note tag I need to use to make the effects actually happening?

P.S: yes, it's a bit more circuitous than probably needed, but I want it that way to reduce inconsistency in the long term and reduce time-wasting maintenance which would occur by copying the code over and over again. If I need to change the base mechanics, then I need to remake it for every item, which I want to make obsolete.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,485
Reaction score
3,514
First Language
EN
Primarily Uses
RMMZ
I imagine it's a silent syntax error causing all the code the tag to be skipped. That's how the YEP library for MV handles things, anyway. If you're lucky it might log console errors: press F8 during playtest to show dev tools and look for red text on the Console tab.

Since the plugin's help states it is "aimed at" Game_Action.prototype.apply, I assume this references the relevant Game_Action instance. Game_Action does not have an itemId method in the core scripts...I'd consider something like this instead:

target.gainTp((parseInt(this.item().meta.TpCost, 10)) * -1);
You might just be able to use parseInt(item.meta.TpCost, 10) instead, it depends on what local variables VisuStella Battle Core defines for that feature.

(Alternatively, if the item has Scope: None, it has no targets and therefore never gets applied. I assume that's not the issue here, though, because your tag explicitly references target. The Common Event effect is a special case, it always applies when the action starts.)
Edit - I just noticed you already have a thread for this here:

Please do not make multiple threads for the same question. Closing this.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Came back cuz of the sale. Got MZ. The System 2 advanced settings for UI are so frustrating, and I see we still hate pixel fonts. Marvelous.
Did another YouTube short. This one has like 1k views (or maybe 380? Analytics is being weird). Getting them zoomer views, yo!
Done edit sprite Raven witch char for main party.
niagarabekasi.jpg

Dirty waterfall in satelite city bekasi.
credit: Hiddeone for knight, LadyBaskerville XP to MV, whtdragon for reindeer, witch nude body by RayaneFLX
I'm really sorry I haven't done any streams. I actually just got home from the hospital after a week and a half.
I'm not dead - I promise :stickytongue:

Anyway, some pokemon inspired art (dont ask me which one tho xD)
reali.png

Forum statistics

Threads
129,718
Messages
1,204,620
Members
170,793
Latest member
duozhengqian321
Top