Drawing Skill Cost in a Separate Window

Hi all!

I am creating a custom window similar to Yanfly's Status_Aid window from the Ace battle engine. In this window, I am planning to put the Actor's current MP, and then the MP cost of the skill currently highlighted in the Skill List (an example of this layout is in most Final Fantasy games). At the moment, I have the window correctly displaying the active actor's MP. The part I am stuck on is drawing the Skill Cost in the window. I figure that if there is a way to draw the skill cost of the current skill window index to another window, I can simply refresh my second window via cursor movement in the skill window to keep the display correct.

I have tried a few methods but it always tosses out errors. Eventually, it'd be nice to expand this window and have it show the relevant resource and cost of the current skill index, but for now I'm just trying to learn how to draw the skill cost. I'm sure it's probably a simple solution, but I am still very inexperienced here. ;;

Thanks so much for any help!
I cant imagine what you want, so could you post a Screenshot of how you want the window to look and how your window looks?
if you already tried a few methods, better post those methods...
Ack, sorry! I guess it seemed clearer in my head, I should have posted examples. ><

Anyway, basically like this:

example.png


I have the window on the right drawn, at the moment all it shows is the Battlemanager.actor's MP and the text. What I am trying to do is draw the MP cost of the current skill window index to the window on the right, like in the example screenshot. What has gotten me the closest is:

draw_text(10, 10, 120, WLH * 2, @actor.skill_mp_cost(index), 1)

Which gives me this error:

error2.png


I am assuming it's pulling the index of the current window. I have tried @skill_window.index, but that doesn't work. I think I just need to pull the current index of the skill window and it should work? I'm really inexperienced at this stuff I usually just frankenscript things and try to learn what stuff does as I go.

Sorry to be vague before I was posting in something of a hurry, and thank you! ^^
we need to know exactly where (which Class and method) you're trying to use that line
Oh, sorry. My bad, I'm being an idiot and not providing the needed info. ;;

class Window_MP < Window_SkillList WLH = 24 def initialize(actor, x = 5, y = 5) super(0, 220, 96*2 - WLH, WLH * 3) self.z = 255 @actor = BattleManager.actor refresh end def refresh draw_actor_mp(@actor, 0, WLH * 0) draw_text(10, 10, 120, WLH * 1, 'MP Needed', 1) draw_text(10, 10, 120, WLH * 2, @actor.skill_mp_cost(index), 1) endendThat's the code that draws the window. Is that what you needed to see? I'm sorry to be such a pain. ><
I think index might not be giving a correct value here causing the problems... try to change it to

SceneManager.scene.skill_window.index

also you might need to add this snippet

Code:
class Scene_Battle  attr_accessor :skill_windowend
I changed the line to the following, and also added that snippet:

draw_text(10, 10, 120, WLH * 3, @actor.skill_mp_cost(SceneManager.scene.skill_window.index), 1

Now I get this error:

error3.png


So that definitely did something, as now it is showing 0 instead of -1 (which means it's now getting the index correctly, right?), but for some reason it's still erroring out, and I'm not sure why. ;;

Thank you for the help so far!
Wait, try


@actor.skill_mp_cost(SceneManager.scene.skill_window.item)
It works! Thank you so much! Looking through the methods I see now why item works and index didn't.

Thank you again. Definitely learned something here. ^^
BattlerBase's skill_mp_cost takes a skill object as argument.


You want to use @skill_window.item for the argument.
Well, everything is working and I have the window properly updating as you select skills, but now I have another odd problem.

For some reason, I can't move the window's X coordinates. No matter what I set the x coordinate as, it appears here:

error4.png


Don't mind the formatting and the fact that the old skill costs are still there, it's very much a WIP, wanted to get the window sized/positioned before I sort all that out. What's strange is, I can adjust the y, window width, height, etc, but it refuses to acknowledge my x coordinate setting and always appears right there.

What's even weirder is that it won't appear at all unless I go directly into Scene_Battle and place create_mp_window above create_info_viewport. The code for the window is above (the only change I made is not calling refresh until the skill window is open as it threw out an error without an active actor, and made self.visible = false at the start of battle), here is my code for creating it:

class Scene_Battle < Scene_Base def create_mp_window @mp_window = Window_MP.new @mp_window.x = 400 end def mp_refresh    @mp_window.refresh  endendThe refresh method is called in process handling in the skill window to update the MP cost. That works just fine. The strange thing is the window won't show at all if I create an alias and draw it there. It only draws if I go directly into Scene_Battle and place create_mp_window ABOVE create_info_viewport.

def create_all_windows create_message_window create_scroll_text_window create_log_window create_status_window create_mp_window create_info_viewport create_party_command_window create_actor_command_window create_help_window create_skill_window create_defrow_window create_item_window create_actor_window create_enemy_window create_ailment_window endI have a couple of other custom windows I have made, they work fine. For some reason however, this one refuses to. Literally the only other code related to it is @mp_window.show and mp_refresh being called in command_skill. I don't get why it only shows up when placed like this, and then is not movable on the x axis.

Again, it's probably something really stupid on my part. ><

EDIT: I fixed the problem by moving the window in the refresh method. I still did something wrong I think because I shouldn't have to do that, but it did work. ;;
Maybe a problem with the viewport used... or maybe you have some method inside the class that actually moved it

Original thread: https://forums.rpgmakerweb.com/threads/drawing-skill-cost-in-a-separate-window.25172/