Need Help Selecting Actor - SOLVED!

Status
Not open for further replies.

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
810
First Language
English
Primarily Uses
RMMV
So I have this line of code and it runs perfectly:$gameActors.actor(1).getTreesPoints(skillTree);

It returns the value for the current amount of free SP (skill points) actor 1 has available. However, I need to make it so that it grabs the amount of SP for actors 2 & 3 accordingly. This is what it looks like atm:
1594455351064.png

If I had a 2nd or 3rd actor in the party, they would simply show the amount of SP of actor 1 instead of their own. This is the code I added in YEP_JobPoints to obtain the result in the screenshot:
JavaScript:
Window_Base.prototype.drawActorJp = function(actor, id, wx, wy, ww, align) {
    var jp = actor.jp(id);
    var icon = '\\i[' + Yanfly.Icon.Jp + ']';
    var fmt = Yanfly.Param.JpMenuFormat;
    var sp = $gameActors.actor(1).getTreesPoints(skillTree); //Shows actor's available Skill Points
    var text = fmt.format(Yanfly.Util.toGroup(jp), Yanfly.Param.Jp, icon) + '  ' + sp + '\\i[157]';
    if (align === 'left') {
      wx = 0;
    } else if (align === 'center') {
      wx += (ww - this.textWidthEx(text)) / 2;
    } else {
      wx += ww - this.textWidthEx(text);
    }
    this.drawTextEx(text, wx, wy);
};
So my question is: What do I use instead of $gameActors.actor(1).getTreesPoints(skillTree); so that it targets the corresponding actors like how JP (job point) does?

I haven't figured out how JP targets the corresponding actor to get their current JP, but however it does it, I need to do it for SP as well...
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,677
Reaction score
13,301
First Language
English
Primarily Uses
RMMV
The actor object is being passed into the function, so you just need to use that rather than $gameActors(anything).

Code:
Window_Base.prototype.drawActorJp = function(actor, id, wx, wy, ww, align) {
    var jp = actor.jp(id);
    var icon = '\\i[' + Yanfly.Icon.Jp + ']';
    var fmt = Yanfly.Param.JpMenuFormat;
    var sp = actor.getTreesPoints(skillTree); //Shows actor's available Skill Points
    var text = fmt.format(Yanfly.Util.toGroup(jp), Yanfly.Param.Jp, icon) + '  ' + sp + '\\i[157]';
    if (align === 'left') {
      wx = 0;
    } else if (align === 'center') {
      wx += (ww - this.textWidthEx(text)) / 2;
    } else {
      wx += ww - this.textWidthEx(text);
    }
    this.drawTextEx(text, wx, wy);
};

What is the id that's being passed in? Are the parameters passed into the function the same as Yanfly's original code, or did you add to them?

Also, what is skillTree and where is it defined? Is it something that belongs to each actor? It hasn't been passed in to the function, and is not defined within the function. So unless skillTree is a property of Window_Base, this is probably going to crash.
 
Last edited:

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
810
First Language
English
Primarily Uses
RMMV
The only thing I added was the line w/ var sp = and also the + ' ' + sp + '\\i[157]'at the end of the line after that.

Edit: Eureka! Your changes worked!:kaojoy:

Btw, which looks better? With or w/o extra spaces?
1594458679054.png

@Shaz To answer your question, skillTree is from @SomeFire's SkillTreesSystem.js plugin.
 
Last edited:

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
810
First Language
English
Primarily Uses
RMMV
Crap, after enabling Galv_BustMenu plugin, SP no longer shows up for actors 2 & 3! It worked when Galv's plugin was off.

Screenshot:
1594525604527.png

Ignore the fact that the location for the SP icon is all messed up in the bottom screenshot. It's because the settings are currently tuned for the bust menu layout. As you can see in the default layout, SP appears for both actors just fine (the blue icon). However, when I switch to the bust layout, only actor 1's SP icon shows. I imagine it has something to do with how JP is called in Galv's plugin.

This is what the code in YEP_JobPoints looks like: (edited to show SP from @SomeFire's skill tree plugin)
JavaScript:
Window_Base.prototype.drawActorJp = function(actor, id, wx, wy, ww, align) {
    var jp = actor.jp(id);
    var icon = '\\i[' + Yanfly.Icon.Jp + ']';
    var fmt = Yanfly.Param.JpMenuFormat;
    var sp = String(actor.getTreesPoints(skillTree) + '\\i[157]'); //Shows actor's available Skill Points
    var text = fmt.format(Yanfly.Util.toGroup(jp), Yanfly.Param.Jp, icon);
    if (align === 'left') {
      wx = 0;
    } else if (align === 'center') {
      wx += (ww - this.textWidthEx(text)) / 2;
    } else {
      wx += ww - this.textWidthEx(text);
    }
    this.drawTextEx(text, wx + 2, wy);
    this.drawTextEx(sp, ww - this.textWidthEx(sp) + 7, wy + 32); //Skill Points
};
So is this an issue with Galv_BustMenu.js or YEP_JobPoints.js? Or maybe it's due to the way I coded the positioning for the SP icon/text? Maybe it really is drawing it for the other actors, but is simply being drawn at the same location multiple times? I really can't tell, it's merely a guess. Help?

Edit: Oops, just realized I double posted...my bad.

Edit2: It looks like my suspicions were correct. SP for actor 2 & 3 are being drawn but on top of actor 1's.
1594529018874.png

I have no idea how to approach/fix this issue. Changing the positioning in YEP_JobPoints would affect all actors equally. I don't know how the Galv plugin was able to get JP to be drawn in the correct positions...

Edit3: Ok, I thought of a potential solution but I'm having trouble getting the syntax right. Basically I'm going to introduce a conditional statement for drawing SP.

if (this.actor.actorId() = 1) <- What's the correct way to write this? (currently throws an undefined error)

Edit4: Huzzah!! I did it!
menu.png
JavaScript:
Window_Base.prototype.drawActorJp = function(actor, id, wx, wy, ww, align) {
    var jp = actor.jp(id);
    var icon = '\\i[' + Yanfly.Icon.Jp + ']';
    var fmt = Yanfly.Param.JpMenuFormat;
    var sp = String(actor.getTreesPoints(skillTree) + '\\i[157]'); //Shows actor's available Skill Points
    var text = fmt.format(Yanfly.Util.toGroup(jp), Yanfly.Param.Jp, icon);
    if (align === 'left') {
      wx = 0;
    } else if (align === 'center') {
      wx += (ww - this.textWidthEx(text)) / 2;
    } else {
      wx += ww - this.textWidthEx(text);
    }
    this.drawTextEx(text, wx + 2, wy);
    if (this.actorId = 1) {
      this.drawTextEx(sp, ww - this.textWidthEx(sp) + 7, wy + 32); //Skill Points
    }
    if (this.actorId = 2) {
      this.drawTextEx(sp, ww - this.textWidthEx(sp) + 239, wy + 32); //Skill Points
    }
    if (this.actorId = 3) {
      this.drawTextEx(sp, ww - this.textWidthEx(sp) + 471, wy + 32); //Skill Points
    }
};
Edit5: Sigh, copies of the SP icon and text are still being drawn underneath actor 1's SP icon/text. MV must hate me... /suicide X.X
 
Last edited:

SomeFire

Veteran
Veteran
Joined
May 27, 2016
Messages
75
Reaction score
97
First Language
Russian
Primarily Uses
actor.getTreesPoints(skillTree) -> actor.getTreesPoints()
Because you don't need a skillTree to get points from single pool.

if (this.actor.actorId() = 1) -> if (this.actor.actorId() == 1)
`=` - set variable, `==` - comparison.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
810
First Language
English
Primarily Uses
RMMV
actor.getTreesPoints(skillTree) -> actor.getTreesPoints()
Because you don't need a skillTree to get points from single pool.

if (this.actor.actorId() = 1) -> if (this.actor.actorId() == 1)
`=` - set variable, `==` - comparison.
I get a "this.actorId is not a function" when I try if (this.actor.actorId() == 1)
or even just (this.actor.actorId() = 1) gives the same error.

When I try (this.actor.actorId == 1) the SP icon/text doesn't get drawn.
Using (this.actor.actorId = 1) gives the result in the above screenshots.

Changing to actor.getTreesPoints() worked flawlessly though, so thank you!
My only issue left is that 3 instances of the SP text/icon get drawn at the same position (where actor 1 is).

Current code:
JavaScript:
Window_Base.prototype.drawActorJp = function(actor, id, wx, wy, ww, align) {
    var jp = actor.jp(id);
    var icon = '\\i[' + Yanfly.Icon.Jp + ']';
    var fmt = Yanfly.Param.JpMenuFormat;
    var sp = String(actor.getTreesPoints() + '\\i[157]'); //Shows actor's available Skill Points
    var text = fmt.format(Yanfly.Util.toGroup(jp), Yanfly.Param.Jp, icon);
    if (align === 'left') {
      wx = 0;
    } else if (align === 'center') {
      wx += (ww - this.textWidthEx(text)) / 2;
    } else {
      wx += ww - this.textWidthEx(text);
    }
    this.drawTextEx(text, wx + 2, wy);
    if (this.actorId = 1) {
      this.drawTextEx(sp, ww - this.textWidthEx(sp) + 7, wy + 32); //Skill Points
    }
//    if (this.actorId = 2) {
//      this.drawTextEx(sp, ww - this.textWidthEx(sp) + 239, wy + 32); //Skill Points
//    }
//    if (this.actorId = 3) {
//      this.drawTextEx(sp, ww - this.textWidthEx(sp) + 471, wy + 32); //Skill Points
//    }
};
Screenshot:
1594542120058.png
 
Last edited:

SomeFire

Veteran
Veteran
Joined
May 27, 2016
Messages
75
Reaction score
97
First Language
Russian
Primarily Uses
Because condition (this.actorId = 1) is always true: this condition means you set this.actorId to 1 and check that it is exists. (this.actorId = 1) -> (1) -> (true)

Try (this.actor._actorId == 1). Also, you can write console.log(this.actor._actorId) to see what is inside variable. And next step to learn debug is to place a breakpoint at drawing line and see all variables together.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
810
First Language
English
Primarily Uses
RMMV
Because condition (this.actorId = 1) is always true: this condition means you set this.actorId to 1 and check that it is exists. (this.actorId = 1) -> (1) -> (true)

Try (this.actor._actorId == 1). Also, you can write console.log(this.actor._actorId) to see what is inside variable. And next step to learn debug is to place a breakpoint at drawing line and see all variables together.
I just tried it: "Cannot read property '_actorId' of undefined"
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
810
First Language
English
Primarily Uses
RMMV
Idk, I thought I needed it so it would target the correct actor. /shrug
I got rid of it and used this:
JavaScript:
    if (actor._actorId == 1) {
      this.drawTextEx(sp, ww - this.textWidthEx(sp) + 7, wy + 32); //Skill Points
    }
But the result was no SP icon/text being drawn... But at least it didn't throw an error! lol

The SP icon/text does get drawn w/o the conditional statement, but the issue is all 3 instances of SP icon/text for each actor gets drawn at the same location...
 

SomeFire

Veteran
Veteran
Joined
May 27, 2016
Messages
75
Reaction score
97
First Language
Russian
Primarily Uses
Now start the game, press F8 (it should open developer tools) before opening menu, go to `Sources` tab, find your script, click on line number of line if (actor._actorId == 1) { (line number will be colored with blue background, that means breakpoint was created at this line). After that - open menu, game should be paused at breakpoint. Find `Scope` section in the right side of the window. Here you can find all variables for this line of code. So, you can check actor id, text you trying to display, coordinates for this text, etc.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
810
First Language
English
Primarily Uses
RMMV
Turns out the solution was to create an entirely new function instead of adding on to the existing one for drawing JP. So I made one in order to draw SP.
JavaScript:
Window_Base.prototype.drawActorSp = function(actor, id, wx, wy, ww, align) {
    var text = String(actor.getTreesPoints() + '\\i[157]'); //Skill Points
    if (align === 'left') {
      wx = 0;
    } else if (align === 'center') {
      wx += (ww - this.textWidthEx(text)) / 2;
    } else {
      wx += ww - this.textWidthEx(text);
    }
    this.drawTextEx(text, wx + 2, wy + 32); //Shows actor's available Skill Points
};
Then I had to go into Galv_BustMenu.js and add:
this.drawActorSp(actor, classId, x, y + lineHeight * Galv.BM.JP, width2, 'right');

Screenshot: (Everything works flawlessly now!)
1594547143338.png

Thank you @SomeFire, I couldn't have done it w/o you lol.:kaopride:
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,025
Reaction score
4,767
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

One 3-day jam and a Game Awards... this month is moving... \o/
Maker-ing has been being the best thing that happened to me this year so far. it is so good to rescue some old skills fo creativity and the people I have met are really incredible. I love my coffelanders and tocudos buddies. Maybe one day I will reach other countries folks too. S2
Well... My game plays better at 1920x1080, so I guess that's the new resolution. Still runs at 60FPS. :LZSexcite: Also... I really want a boss to be able to build new maps around the player... Mostly because it's visually spectacular! I'm er... not quite sure yet how I can do that without making MV explode.... But I'll find a way, anything in service to the "sparkles"! :kaopride:
How to change your netbooks screen resolution

Forum statistics

Threads
100,791
Messages
979,592
Members
132,436
Latest member
jefigeb851
Top