Jump to content
Darkwes

Darkwes - Simple Variable Window

Recommended Posts

Well, I did this while I was bored after someone asked how to show some values on a window, so maybe this may be useful to someone else since it can be used for nearly anything you want to control with variables and show to the player. :P

 

This is a REALLY simple script (I'm not a scripter btw, I just can figure it out how things work sometimes) :P

 

 

X4u99Uh.jpg?1

 

 

 

#==============================================================================
# ** Simple Variable Window a.k.a. Not so Awesome Job Window by Darkwes
#==============================================================================

class Scene_Jobs < Scene_MenuBase

  def start
    super
    @jobs_window = Window_Jobs.new(@actor)
    @jobs_window.set_handler(:cancel,   method(:return_scene))
  end
end

class Window_Jobs < Window_Selectable

  def initialize(actor)
    super(0, 0, Graphics.width, Graphics.height)
    @actor = actor
    refresh
    activate
  end

  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end

  def refresh
    contents.clear
    draw_block1   (line_height * 0)
    draw_horz_line(line_height * 1)
    draw_block2   (line_height * 2)
  end

  def draw_block1(y)
    draw_actor_name(@actor, 4, y)
    draw_actor_class(@actor, 128, y)
    draw_actor_nickname(@actor, 288, y)
  end

  def draw_block2(y)
    draw_actor_face(@actor, 8, y)
    draw_job_info(136, y)
  end

  def draw_horz_line(y)
    line_y = y + line_height / 2 - 1
    contents.fill_rect(0, line_y, contents_width, 2, line_color)
  end

  def line_color
    color = normal_color
    color.alpha = 48
    color
  end

  def draw_job_info(x, y)
    change_color(system_color)
    draw_text(x, y + line_height * 0, 96, line_height, "JOBS")
  #--------------------------------------------------------------------------
  # * Change the name of the jobs below
  #--------------------------------------------------------------------------
    draw_text(x, y + line_height * 1, 96, line_height, "Job 1")
    draw_text(x, y + line_height * 2, 96, line_height, "Job 2")
    draw_text(x, y + line_height * 3, 96, line_height, "Job 3")
    draw_text(x, y + line_height * 4, 96, line_height, "Job 4")
    draw_text(x, y + line_height * 5, 96, line_height, "Job 5")
    draw_text(x, y + line_height * 6, 96, line_height, "Job 6")
    draw_text(x, y + line_height * 7, 96, line_height, "Job 7")
    draw_text(x, y + line_height * 8, 96, line_height, "Job 8")
    draw_text(x, y + line_height * 9, 96, line_height, "Job 9")
    draw_text(x, y + line_height * 10, 96, line_height, "Job 10")
    
    # Don't change this one 
    draw_text(x + 128, y + line_height * 0, 96, line_height, "LEVEL", 2)
    change_color(normal_color)    
  #--------------------------------------------------------------------------
  # * Change the variables that handles the job levels below
  #--------------------------------------------------------------------------
    draw_text(x + 128, y + line_height * 1, 96, line_height, $game_variables[1], 2)
    draw_text(x + 128, y + line_height * 2, 96, line_height, $game_variables[2], 2)
    draw_text(x + 128, y + line_height * 3, 96, line_height, $game_variables[3], 2)
    draw_text(x + 128, y + line_height * 4, 96, line_height, $game_variables[4], 2)
    draw_text(x + 128, y + line_height * 5, 96, line_height, $game_variables[5], 2)
    draw_text(x + 128, y + line_height * 6, 96, line_height, $game_variables[6], 2)
    draw_text(x + 128, y + line_height * 7, 96, line_height, $game_variables[7], 2)
    draw_text(x + 128, y + line_height * 8, 96, line_height, $game_variables[8], 2)
    draw_text(x + 128, y + line_height * 9, 96, line_height, $game_variables[9], 2)
    draw_text(x + 128, y + line_height * 10, 96, line_height, $game_variables[10], 2)
  end
end

 

 

 

Instructions:

- You can Change the "JOBS" for whatever term you need on the line 62.

- Edit the lines 66 to 75 to show the actual name of the jobs or w/e else you're making with the variables (delete some of those lines if you not going to use everything or simple add a # before them).

- Edit the lines 83 to 92 to show the variable value that handle the level of the jobs/whatever (delete some those lines if you not going to use everything or simple add a # before them).

- Use an event script call to show the Job window or you can add it to a menu, etc, with:

 

SceneManager.call(Scene_Jobs)

 

*Obs.: The Face/Name/Nickname shown will be of the the party leader because I was lazy to proper script it :P

 

*Free for non-commercial use. Credit is appreciated. :)

Edited by Darkwes

Share this post


Link to post
Share on other sites

very good... i can change the variables by parameters? or other command? i can add more variables?

Share this post


Link to post
Share on other sites

i get change... only create variables which show these parameters and add... is more easy..

only i have a doubt... how can increase the max number of variables (10) for 15 or more?

nice script... help so much

Share this post


Link to post
Share on other sites

15 variables won't fit on the screen like that xD

 

 

Well, actually it only needs to be split into 2 columns like this:

 

yMzDHxM.jpg?1

 

 

 

#==============================================================================
# ** Simple Variable Window a.k.a. Not so Awesome Job Window by Darkwes
#==============================================================================

class Scene_Jobs < Scene_MenuBase

  def start
    super
    @jobs_window = Window_Jobs.new(@actor)
    @jobs_window.set_handler(:cancel,   method(:return_scene))
  end
end

class Window_Jobs < Window_Selectable

  def initialize(actor)
    super(0, 0, Graphics.width, Graphics.height)
    @actor = actor
    refresh
    activate
  end

  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end

  def refresh
    contents.clear
    draw_block1   (line_height * 0)
    draw_horz_line(line_height * 1)
    draw_block2   (line_height * 2)
  end

  def draw_block1(y)
    draw_actor_name(@actor, 4, y)
    draw_actor_class(@actor, 128, y)
    draw_actor_nickname(@actor, 288, y)
  end

  def draw_block2(y)
    draw_actor_face(@actor, 8, y)
    draw_job_info(136, y)
  end

  def draw_horz_line(y)
    line_y = y + line_height / 2 - 1
    contents.fill_rect(0, line_y, contents_width, 2, line_color)
  end

  def line_color
    color = normal_color
    color.alpha = 48
    color
  end

  def draw_job_info(x, y)
    change_color(system_color)
    draw_text(x, y + line_height * 0, 96, line_height, "JOBS")
    draw_text(x + 192, y + line_height * 0, 96, line_height, "JOBS")
  #--------------------------------------------------------------------------
  # * Change the name of the jobs below
  #--------------------------------------------------------------------------
    draw_text(x, y + line_height * 1, 72, line_height, "Job 1")
    draw_text(x, y + line_height * 2, 72, line_height, "Job 2")
    draw_text(x, y + line_height * 3, 72, line_height, "Job 3")
    draw_text(x, y + line_height * 4, 72, line_height, "Job 4")
    draw_text(x, y + line_height * 5, 72, line_height, "Job 5")
    draw_text(x, y + line_height * 6, 72, line_height, "Job 6")
    draw_text(x, y + line_height * 7, 72, line_height, "Job 7")
    draw_text(x, y + line_height * 8, 72, line_height, "Job 8")
    draw_text(x, y + line_height * 9, 72, line_height, "Job 9")
    draw_text(x, y + line_height * 10, 72, line_height, "Job 10")
    draw_text(x + 192, y + line_height * 1, 72, line_height, "Job 11")
    draw_text(x + 192, y + line_height * 2, 72, line_height, "Job 12")
    draw_text(x + 192, y + line_height * 3, 72, line_height, "Job 13")
    draw_text(x + 192, y + line_height * 4, 72, line_height, "Job 14")
    draw_text(x + 192, y + line_height * 5, 72, line_height, "Job 15")
    draw_text(x + 192, y + line_height * 6, 72, line_height, "Job 16")
    draw_text(x + 192, y + line_height * 7, 72, line_height, "Job 17")
    draw_text(x + 192, y + line_height * 8, 72, line_height, "Job 18")
    draw_text(x + 192, y + line_height * 9, 72, line_height, "Job 19")
    draw_text(x + 192, y + line_height * 10, 72, line_height, "Job 20")
    
    # Don't change this one 
    draw_text(x + 72, y + line_height * 0, 96, line_height, "LEVEL", 2)
    draw_text(x + 264, y + line_height * 0, 96, line_height, "LEVEL", 2)
    change_color(normal_color)    
  #--------------------------------------------------------------------------
  # * Change the variables that handles the job levels below
  #--------------------------------------------------------------------------
    draw_text(x + 96, y + line_height * 1, 72, line_height, $game_variables[1], 2)
    draw_text(x + 96, y + line_height * 2, 72, line_height, $game_variables[2], 2)
    draw_text(x + 96, y + line_height * 3, 72, line_height, $game_variables[3], 2)
    draw_text(x + 96, y + line_height * 4, 72, line_height, $game_variables[4], 2)
    draw_text(x + 96, y + line_height * 5, 72, line_height, $game_variables[5], 2)
    draw_text(x + 96, y + line_height * 6, 72, line_height, $game_variables[6], 2)
    draw_text(x + 96, y + line_height * 7, 72, line_height, $game_variables[7], 2)
    draw_text(x + 96, y + line_height * 8, 72, line_height, $game_variables[8], 2)
    draw_text(x + 96, y + line_height * 9, 72, line_height, $game_variables[9], 2)
    draw_text(x + 96, y + line_height * 10, 72, line_height, $game_variables[10], 2)
    draw_text(x + 288, y + line_height * 1, 72, line_height, $game_variables[11], 2)
    draw_text(x + 288, y + line_height * 2, 72, line_height, $game_variables[12], 2)
    draw_text(x + 288, y + line_height * 3, 72, line_height, $game_variables[13], 2)
    draw_text(x + 288, y + line_height * 4, 72, line_height, $game_variables[14], 2)
    draw_text(x + 288, y + line_height * 5, 72, line_height, $game_variables[15], 2)
    draw_text(x + 288, y + line_height * 6, 72, line_height, $game_variables[16], 2)
    draw_text(x + 288, y + line_height * 7, 72, line_height, $game_variables[17], 2)
    draw_text(x + 288, y + line_height * 8, 72, line_height, $game_variables[18], 2)
    draw_text(x + 288, y + line_height * 9, 72, line_height, $game_variables[19], 2)
    draw_text(x + 288, y + line_height * 10, 72, line_height, $game_variables[20], 2)
  end
end

 

 

Edited by Darkwes

Share this post


Link to post
Share on other sites

wow! Thank you very much! You could add an option to change party members by pressing L and R? As in the status menu?

Share this post


Link to post
Share on other sites

Yeah that can be done and it is simple, but there will be a problem doing that, since the code only shows static variables and you'll probably want to show different ones for each actor. That can also be done, but in order to not overuse the variables, it should be made with the exact amount of actors and variables you'll need.

Share this post


Link to post
Share on other sites
I created the variables to display the attributes of the characters, for example: $game_party.members [0].hit 

I changed the name "job" to "accuracy" and added the value of the variable .. 

for example, 0.95 is shown to character id1, and exchanging the leader through the menu shows 0.96 to character id2 .. 

how have you teach me how change the heroes in own window? 

ah and you think if you put 30 variables (3 columns) would be ugly?

Share this post


Link to post
Share on other sites

Not sure if I did understood what you said. About changing the actor info, just change the script for this one.

 

 

 

#==============================================================================
# ** Simple Variable Window a.k.a. Not so Awesome Job Window by Darkwes
#==============================================================================

class Scene_Jobs < Scene_MenuBase

  def start
    super
    @jobs_window = Window_Jobs.new(@actor)
    @jobs_window.set_handler(:cancel,   method(:return_scene))
    @jobs_window.set_handler(:pagedown, method(:next_actor))
    @jobs_window.set_handler(:pageup,   method(:prev_actor))
  end
  def on_actor_change
    @jobs_window.actor = @actor
    @jobs_window.activate
  end
end

class Window_Jobs < Window_Selectable

  def initialize(actor)
    super(0, 0, Graphics.width, Graphics.height)
    @actor = actor
    refresh
    activate
  end

  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end

  def refresh
    contents.clear
    draw_block1   (line_height * 0)
    draw_horz_line(line_height * 1)
    draw_block2   (line_height * 2)
  end

  def draw_block1(y)
    draw_actor_name(@actor, 4, y)
    draw_actor_class(@actor, 128, y)
    draw_actor_nickname(@actor, 288, y)
  end

  def draw_block2(y)
    draw_actor_face(@actor, 8, y)
    draw_job_info(136, y)
  end

  def draw_horz_line(y)
    line_y = y + line_height / 2 - 1
    contents.fill_rect(0, line_y, contents_width, 2, line_color)
  end

  def line_color
    color = normal_color
    color.alpha = 48
    color
  end

  def draw_job_info(x, y)
    change_color(system_color)
    draw_text(x, y + line_height * 0, 96, line_height, "JOBS")
    draw_text(x + 192, y + line_height * 0, 96, line_height, "JOBS")
  #--------------------------------------------------------------------------
  # * Change the name of the jobs below
  #--------------------------------------------------------------------------
    draw_text(x, y + line_height * 1, 72, line_height, "Job 1")
    draw_text(x, y + line_height * 2, 72, line_height, "Job 2")
    draw_text(x, y + line_height * 3, 72, line_height, "Job 3")
    draw_text(x, y + line_height * 4, 72, line_height, "Job 4")
    draw_text(x, y + line_height * 5, 72, line_height, "Job 5")
    draw_text(x, y + line_height * 6, 72, line_height, "Job 6")
    draw_text(x, y + line_height * 7, 72, line_height, "Job 7")
    draw_text(x, y + line_height * 8, 72, line_height, "Job 8")
    draw_text(x, y + line_height * 9, 72, line_height, "Job 9")
    draw_text(x, y + line_height * 10, 72, line_height, "Job 10")
    draw_text(x + 192, y + line_height * 1, 72, line_height, "Job 11")
    draw_text(x + 192, y + line_height * 2, 72, line_height, "Job 12")
    draw_text(x + 192, y + line_height * 3, 72, line_height, "Job 13")
    draw_text(x + 192, y + line_height * 4, 72, line_height, "Job 14")
    draw_text(x + 192, y + line_height * 5, 72, line_height, "Job 15")
    draw_text(x + 192, y + line_height * 6, 72, line_height, "Job 16")
    draw_text(x + 192, y + line_height * 7, 72, line_height, "Job 17")
    draw_text(x + 192, y + line_height * 8, 72, line_height, "Job 18")
    draw_text(x + 192, y + line_height * 9, 72, line_height, "Job 19")
    draw_text(x + 192, y + line_height * 10, 72, line_height, "Job 20")
    
    # Don't change this one 
    draw_text(x + 72, y + line_height * 0, 96, line_height, "LEVEL", 2)
    draw_text(x + 264, y + line_height * 0, 96, line_height, "LEVEL", 2)
    change_color(normal_color)    
  #--------------------------------------------------------------------------
  # * Change the variables that handles the job levels below
  #--------------------------------------------------------------------------
    draw_text(x + 96, y + line_height * 1, 72, line_height, $game_variables[1], 2)
    draw_text(x + 96, y + line_height * 2, 72, line_height, $game_variables[2], 2)
    draw_text(x + 96, y + line_height * 3, 72, line_height, $game_variables[3], 2)
    draw_text(x + 96, y + line_height * 4, 72, line_height, $game_variables[4], 2)
    draw_text(x + 96, y + line_height * 5, 72, line_height, $game_variables[5], 2)
    draw_text(x + 96, y + line_height * 6, 72, line_height, $game_variables[6], 2)
    draw_text(x + 96, y + line_height * 7, 72, line_height, $game_variables[7], 2)
    draw_text(x + 96, y + line_height * 8, 72, line_height, $game_variables[8], 2)
    draw_text(x + 96, y + line_height * 9, 72, line_height, $game_variables[9], 2)
    draw_text(x + 96, y + line_height * 10, 72, line_height, $game_variables[10], 2)
    draw_text(x + 288, y + line_height * 1, 72, line_height, $game_variables[11], 2)
    draw_text(x + 288, y + line_height * 2, 72, line_height, $game_variables[12], 2)
    draw_text(x + 288, y + line_height * 3, 72, line_height, $game_variables[13], 2)
    draw_text(x + 288, y + line_height * 4, 72, line_height, $game_variables[14], 2)
    draw_text(x + 288, y + line_height * 5, 72, line_height, $game_variables[15], 2)
    draw_text(x + 288, y + line_height * 6, 72, line_height, $game_variables[16], 2)
    draw_text(x + 288, y + line_height * 7, 72, line_height, $game_variables[17], 2)
    draw_text(x + 288, y + line_height * 8, 72, line_height, $game_variables[18], 2)
    draw_text(x + 288, y + line_height * 9, 72, line_height, $game_variables[19], 2)
    draw_text(x + 288, y + line_height * 10, 72, line_height, $game_variables[20], 2)
  end
end

 

 

 

About the 3 columns, it won't look good as it is now, I'll have to change a lot of the text positions.

Edited by Darkwes

Share this post


Link to post
Share on other sites
the change did not work right ... because I define the variables by the leader, so to move the window, q would change leader also ... 

I've been testing and saw that the window allows up to 13 lines, leaving her more satisfied 

thank you  ;)

Share this post


Link to post
Share on other sites

Advice: Please use Looping instead of copy-paste-ing a list of 20 draw_text()s

Example:

10.times {|i| draw_text(x + 96, y + line_height * i, 72, line_height, $game_variables[i], 2)}

It does work the same, but it looks more "professional"

Share this post


Link to post
Share on other sites

Advice: Please use Looping instead of copy-paste-ing a list of 20 draw_text()s

Example:

10.times {|i| draw_text(x + 96, y + line_height * i, 72, line_height, $game_variables[i], 2)}

It does work the same, but it looks more "professional"

As I said, I'm not a scripter.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted