Hellinfernel

Veteran
Veteran
Joined
Jun 26, 2022
Messages
53
Reaction score
7
First Language
German
Primarily Uses
RMMZ
My current problem is the following: I want that an Item does make the following things when being used:
First, it reduces TP by the TpCost of the item (notetag).
Then, it increases the MP, HP and EXP by the associated value that is saved in the notetags.
Now I tried it out, but nothing really happens.
Code:
<JS Pre-Damage>
console.log(this.meta.TpCost);
console.log(this.meta.MpRegen);
console.log(this.meta.HpRegen);
console.log(this.meta.ExpGain);
target.gainTp((parseInt(this.meta.TpCost)) * -1);
target.gainMp(parseInt(this.meta.MpRegen));
target.gainHp(parseInt(this.meta.HpRegen));
target.gainExp(parseInt(this.meta.ExpGain));
</JS Pre-Damage>
My problem is now that I have no idea how to actually find out why nothing happens because this is so much bound to the visustella engine, which is obfuscated.

So my question is:

- How do I debug stuff that comes from other plugins?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,546
Reaction score
5,311
First Language
English
Primarily Uses
RMMV
You don't need to debug stuff in VisuStella's plugins, these issues are readily visible :smile:

Referencing this.meta fields won't work. The in-game objects don't have meta properties, only the database entries do. You would have to do something like $dataItems[this.itemId()].meta

Also, it's a little weird for you to be referencing this in the first place - you'd do that with code that could be operating on different objects, which have potentially different values.

But here, you're entering the code directly on the specific item that you're also going to add this notetag to, so I don't see how it makes sense to not just type the number you want. I can't see any reason to be adding notetags at all.

Lastly as a quick thing I noticed - unless these items have a scope of User, there's a potential logical error because you're subtracting the TP from the target, which is not necessarily the actor using it.
 

Hellinfernel

Veteran
Veteran
Joined
Jun 26, 2022
Messages
53
Reaction score
7
First Language
German
Primarily Uses
RMMZ
Referencing this.meta fields won't work. The in-game objects don't have meta properties, only the database entries do. You would have to do something like $dataItems[this.itemId()].meta

Also, it's a little weird for you to be referencing this in the first place - you'd do that with code that could be operating on different objects, which have potentially different values.
That's the kind of stuff thats making me prefer writing my own plugin rather than relying on the JS notetags. Because the RPG maker isn't really an IDE for JavaScript in that sense. In Visual Studio Code, I get at least some information in what I try to reference. In the rpg maker I don't even see what "this" does mean in the context I use it.
But here, you're entering the code directly on the specific item that you're also going to add this notetag to, so I don't see how it makes sense to not just type the number you want. I can't see any reason to be adding notetags at all.
That's mainly for maintenance reasons - Although I probably think too much in the long term.
It's just to ensure that any item of that category does work with the same code.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,546
Reaction score
5,311
First Language
English
Primarily Uses
RMMV
In the rpg maker I don't even see what "this" does mean in the context I use it.
If you're ever confused and need to know, you can stick something like this in your code:
Code:
console.log("Object is ", this.constructor.name);
and that would show in the Console tab that this is a Game_Action.

It's just to ensure that any item of that category does work with the same code.
I just don't really see the point.
Your way:
- You copy the Pre-Damage notetag from one of your items to another
- You copy the four extra notetags from an old item to the new one
- You edit the numbers in those four extra notetags

Or just:
- You copy the Pre-Damage notetag from one of your items to another
- You edit the four numbers in that notetag

It just isn't accomplishing anything because it isn't referencing anything external. All of the actual code is the same.

Edit: It's kinda wasteful to post a new thread asking for help with the exact same piece of code. If there's more of this that isn't working, this is a logical place to say so and continue the discussion in one place.
 
Last edited:

Hellinfernel

Veteran
Veteran
Joined
Jun 26, 2022
Messages
53
Reaction score
7
First Language
German
Primarily Uses
RMMZ
- You copy the Pre-Damage notetag from one of your items to another
That's exactly the thing I need to avoid. Because then they aren't copied permanently. At the moment I need to change the basis mechanic, I need to change every item, and it's pretty much sure that I will miss something when I do that manually. I want, that every item of that category works the same, regardless of how often I change the mechanic that is underlying it.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,546
Reaction score
5,311
First Language
English
Primarily Uses
RMMV
Okay, then getting the code from the database should do it for you. e.g. $dataItems[this.item().id].meta

I know there's translations in play, but it would really help you to get your good answers faster if you provided clearer descriptions of what you're trying to do.

Your other post with this exact same code gave the specific information that you're trying to write this as something that will be inherited by other objects via plugin. But you never said that here, so I wasted our time with going back and forth about the extra notetags.

Let us know if something else doesn't work :wink:
 

Hellinfernel

Veteran
Veteran
Joined
Jun 26, 2022
Messages
53
Reaction score
7
First Language
German
Primarily Uses
RMMZ
Okay, then getting the code from the database should do it for you. e.g. $dataItems[this.item().id].meta

I know there's translations in play, but it would really help you to get your good answers faster if you provided clearer descriptions of what you're trying to do.

Your other post with this exact same code gave the specific information that you're trying to write this as something that will be inherited by other objects via plugin. But you never said that here, so I wasted our time with going back and forth about the extra notetags.

Let us know if something else doesn't work :wink:
My current problem is that I have no idea what is even wrong with my code, simply because the game doesn't complain if the code doesn't work. It just continues, no matter what I do.
Probably it's just a reference error somewhere, but It's impossible to say because nothing gives feedback. I'm just poking around like stupid in the air.

God is that frustrating.

Why can't the game just crash and give me an error log...

EDIT: Currently try to include try catch blocks in the hope that that will give me at least some infos... not with good results...
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,485
Reaction score
3,514
First Language
EN
Primarily Uses
RMMZ
@Hellinfernel - 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.)
 

Hellinfernel

Veteran
Veteran
Joined
Jun 26, 2022
Messages
53
Reaction score
7
First Language
German
Primarily Uses
RMMZ
@Hellinfernel - 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.
Yeah, ehm, that absolutely doesn't sound like a complete nightmare to debug, but, Well, at least I'll know better next time.
1674838848227.png
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,485
Reaction score
3,514
First Language
EN
Primarily Uses
RMMZ
Yeah, I don't know why they do that.
 

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,792
Latest member
Wagner34
Top