MV Player Attributes Plugin

I've been trying to make a plugin that allows the player to distribute 'Skill points' between 6 different attributes, but I can't really code haha.


Variable 0001 = Strength
Variable 0002 = Dexterity
Variable 0003 = Constitution
Variable 0004 = Intelligence
Variable 0005 = Wisdom
Variable 006 = Charisma

Variable 0007 = Skill Points

I'm looking to add 6 buttons in the bottom window that will increase the players stats by spending the Skill Points.

If anyone can help me out or point me in the right direction id be grateful

EDIT:
Spoiler: Code
Moved to: Learning Javascript
I've updated the code but I still need help.
Hi there!

Since you are creating a new scene, I guess the first step is also to create new windows for this scene too.
Meaning, instead of using Window_Base for the Title Window, create a new Window to be the title window(that inherits from the Window Base).

Something like "Window_DistributeSkillTitle", and then create methods on this window to draw the title.

The same behavior is to the Variable window, Sp Window, and Distribute Window.

Like the Scene_Test.prototype.createVariableWindow is doing multiple tasks when the task should be only to create the variable window.
Let the variable window draw its own contents.

This will help you keep things more organized.

On the Distribute window, use the makeCommandList method from the Window_Command to add the commands to distribute the points.
And just use the setHandler method on the scene test function you are creating the window.

You can see examples of this stuff on the RPG Maker code itself. Like the Titlte Command window used on the Scene Title.

I think when you have updated your code this way if you still didn't manage to make what you want, post the update here and I will keep helping you.
Okay, I've done a little research and come back with this.

Spoiler: Code

I still need to add the buttons but your suggestion helped.
Okay, I've done a little research an come back with this.

Spoiler: Code
changing it again

I still need to add the buttons but your suggestion helped.
I can't see your new code here, maybe you didn't paste it?
Also the first one still the same.

As I said, take a look on the Default RPG Maker code, see how they add a new window on the scene. For example the Title Window.
Don't reuse Window_Base and Window_Command.
Create new windows that inherits from them, just like you did with the Scene_Test that inherits from Scene Menu.

Organize your code, to be more "linear". There are Scene_test everywhere on the code.

After that, I believe I can help you better. If you clear things up, it might help you see things that you didn't see before.
I can't see your new code here, maybe you didn't paste it?
Also the first one still the same.

As I said, take a look on the Default RPG Maker code, see how they add a new window on the scene. For example the Title Window.
Don't reuse Window_Base and Window_Command.
Create new windows that inherits from them, just like you did with the Scene_Test that inherits from Scene Menu.

Organize your code, to be more "linear". There are Scene_test everywhere on the code.

After that, I believe I can help you better. If you clear things up, it might help you see things that you didn't see before.
Sorry, I was just changing it a little i've now updated it. I can't get my head around the buttons.

Capture.JPG

The Orange is Ps.
I can't see your new code here, maybe you didn't paste it?
Also the first one still the same.

As I said, take a look on the Default RPG Maker code, see how they add a new window on the scene. For example the Title Window.
Don't reuse Window_Base and Window_Command.
Create new windows that inherits from them, just like you did with the Scene_Test that inherits from Scene Menu.

Organize your code, to be more "linear". There are Scene_test everywhere on the code.

After that, I believe I can help you better. If you clear things up, it might help you see things that you didn't see before.
I'm trying haha, I'm more of an artist I can't really code.
I'm trying haha, I'm more of an artist I can't really code.
But for what you have created yourself, I don't see why you can't do what I tell you.
First, organize your code.

1 - Create new windows for each window of the scene test. They need to inherit from Window Base and Window Command. Just like you did with the Scene Test inherited from Scene Menu.

2 - Now, separate each one on the code, linearly. Meaning:
  • Scene Test codes
  • Window A codes
  • Window B codes
  • etc...
Currently, they are all mixed up:
  • Scene Test codes
  • Window Base codes
  • Scene Test codes
  • Window Base codes
3 - Let each window handle its own content. Currently, you are using the Scene Test to create the Variable window for example, and on that same function, you are making the Scene Test write all text inside the window. Don't do that.
Use the Scene Test to create the windows, then let the windows handle their own content.

I'm saying this stuff for you because as I see what you coded so far, I'm pretty sure you can do what I say.
I still can't get the buttons to work properly.
I believe it's a little better.
Now you need to add a handler for each button. This handler is a callback for each button/command you added to the window.

Usually, these handlers are created within the Scene. But you can also do it through the window itself. Example:

JavaScript:
Window_PlayerAttributes4.prototype.makeCommandList = function() {
    this.addCommand("Str", 'option1');
    this.addCommand("Dex", 'option2');
    this.addCommand("Con", 'option3');
    this.addCommand("Int", 'option4');
    this.addCommand("Wis", 'option5');
    this.addCommand("Cha", 'option6');
    // Add handlers
    this.setHandler("option1", this.onOption1)
};

Window_PlayerAttributes4.prototype.onOption1 = function() {
    // Reduce one skill point
    // Add it to the strenght variable.
};

But, sorry if I'm wrong. I'm giving you detailed answers, and the only answer "I still can't get the buttons to work properly.".

I need more information. Why they do not work? What you are trying to do? What are you not understanding?
Did you take a look into the RPG Maker code part that I talked to you about?

In your code, there is already a function that adds a new command into a Command Window and also a function that works as a handler of this command.
If you manage to do that, why can't you do the same for your Command Window on your custom scene?

So, I have to ask, are you using A.I to create this code?
I needed to set the width and height as it was inherited, it was cutting off the text, so only the first two buttons and half of con was showing.

Window_PlayerAttributes4.prototype.windowHeight = function() { return Graphics.boxHeight * 0.2; }; Window_PlayerAttributes4.prototype.windowWidth = function() { return Graphics.boxWidth; };
I don't know from your last post if you still need help with something.

But as a general bit of logic, it's profoundly unhelpful for you to go back and wipe everything out of your old posts. It makes it impossible for anyone other than Eliaquim to come in and offer any advice.

Original thread: https://forums.rpgmakerweb.com/threads/player-attributes-plugin.155928/