Optimising refresh options?

Hey, everybody! It's been a long time for me, so I hope I'm putting this in the right place!

Also, I've been googling and experimenting for about a week or two with this. Learned a lot, still not getting it. 😀

So, I edited Scene_Map to include a character HUD. It's a pretty basic window that reuses window_status.


Now, in Map_Scene, I have

Spoiler
Code:
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    $game_variables[219] = 200
    super
    SceneManager.clear
    $game_player.straighten
    $game_map.refresh
    $game_message.visible = false
    create_spriteset
    create_all_windows
    @menu_calling = false
    create_gold_window
    create_status_window2
    create_status_window3
    create_status_windowM
    @status_windowM.hide
    @status_window3.hide
    @status_window2.hide
  end


  #create status window here




  def create_status_window2
    @status_window2 = Window_MenuStatus2.new(10, 0)
    @status_window2.x = Graphics.width - 200
    @status_window2.y = 0
  end

  def create_status_window3
    @status_window3 = Window_MenuStatus3.new(10, 0)
    @status_window3.x = 0
    @status_window3.y = Graphics.height - 110
  end

  def create_status_windowM
    @status_windowM = Window_MenuStatusM.new(10, 0)
    @status_windowM.x = 0
    @status_windowM.y = 0
  end




  #create gold window here

  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.x = 2000
    @gold_window.y = 0
  end


  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    $game_map.update(true)
    $game_player.update
    $game_timer.update
    @spriteset.update
    update_scene if scene_change_ok?

    if $game_switches[20] == false
      @status_window2.hide
    else
      @status_window2.show
    end

    if $game_switches[19] == false
      @status_window3.hide
    else
      @status_window3.show
    end

    if $game_switches[18] == false
      @status_windowM.hide
    else
      @status_windowM.show
    end

    @status_window2.refresh
    @status_window3.refresh
    @status_2windowM.refresh






  end

In Window_Base:

Spoiler
Code:
#handles gold window?
 
  def value
    $game_party.gold
  end
  def currency_unit
    Vocab::currency_unit
  end
 
 
 
 
  #--------------------------------------------------------------------------
  # * This is the character hud; can be toggled with "q"
  #--------------------------------------------------------------------------
  def draw_actor_simple_status2(actor, x, y)
    contents.font.size = 20
    draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
    draw_actor_hp(actor, x - 100, y - 15 + 20 * 1)
    draw_actor_mp(actor, x - 100, y - 15 + 20 * 2)
          # adding parameters below
    change_color(normal_color)
 
    contents.font.size = 20
 
    # x start, y start - n + line.height * line, ??, line.height, text
    # Did not redefine line height so I can have more control; though consistantly 20
    # do not merge values, the '20*n' dictates line height
 
 
    # draw player name
    self.contents.font.color = Color.new(244,244,244)
    draw_text(x - 105 , y  -10, 120, 20, $game_actors[1].name)
 
 
 
    self.contents.font.color = Color.new(244,4,244)
    draw_text(x - 105 , y - 10 + 20 * 3, 120, 20, "ATTR")
    draw_text(x - 55 , y - 10 + 20 * 3, 120, 20, "SKL+")
    draw_text(x - 10 , y - 10 + 20 * 3, 120, 20, "BASE=")
    draw_text(x + 45 , y - 10 + 20 * 3, 120, 20, "TOT")
    change_color(normal_color)
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105, y - 10 + 20 * 4, 120, 20, Vocab::param(2))
    change_color(normal_color)
    self.contents.font.color = Color.new(50,154,255)
    draw_text(x - 40, y - 10 + 20 * 4, 120, 20, $game_variables[15])
    change_color(normal_color)
    draw_text(x - 15, y - 10 + 20 * 4, 36, 20, actor.param(2), 2)
    change_color(normal_color)
    self.contents.font.color = Color.new(0,244,4)
    draw_text(x + 50, y - 10 + 20 * 4, 120, 20, $game_variables[1])
    change_color(normal_color)
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105, y - 10 + 20 * 5, 120, 20, Vocab::param(3))
    change_color(normal_color)
    self.contents.font.color = Color.new(50,154,255)
    draw_text(x - 40, y - 10 + 20 * 5, 120, 20, $game_variables[9])
    change_color(normal_color)
    draw_text(x - 15, y - 10 + 20 * 5, 36, 20, actor.param(3), 2)
    change_color(normal_color)
    self.contents.font.color = Color.new(0,244,4)
    draw_text(x + 50, y - 10 + 20 * 5, 120, 20, $game_variables[2])
    change_color(normal_color)
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105, y - 10 + 20 * 6, 120, 20, Vocab::param(4))
    change_color(normal_color)
    self.contents.font.color = Color.new(50,154,255)
    draw_text(x - 40 , y - 10 + 20 * 6, 120, 20, $game_variables[16])
    change_color(normal_color)
    draw_text(x - 15, y - 10 + 20 * 6, 36, 20, actor.param(4), 2)
    change_color(normal_color)
    self.contents.font.color = Color.new(0,244,4)
    draw_text(x + 50, y - 10 + 20 * 6, 120, 20, $game_variables[3])
    change_color(normal_color)
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105, y - 10 + 20 * 7, 120, 20, Vocab::param(5))
    change_color(normal_color)
    self.contents.font.color = Color.new(50,154,255)
    draw_text(x - 40, y - 10 + 20 * 7, 120, 20, $game_variables[9])
    change_color(normal_color)
    draw_text(x - 15, y - 10 + 20 * 7, 36, 20, actor.param(5), 2)
    change_color(normal_color)
    self.contents.font.color = Color.new(0,244,4)
    draw_text(x + 50, y - 10 + 20 * 7, 120, 20, $game_variables[4])
    change_color(normal_color)
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105, y - 10 + 20 * 8, 120, 20, Vocab::param(6))
    change_color(normal_color)
    self.contents.font.color = Color.new(50,154,255)
    draw_text(x - 40, y - 10 + 20 * 8, 120, 20, $game_variables[17])
    change_color(normal_color)
    draw_text(x - 15, y - 10 + 20 * 8, 36, 20, actor.param(6), 2)
    change_color(normal_color)
    self.contents.font.color = Color.new(0,244,4)
    draw_text(x + 50, y - 10 + 20 * 8, 120, 20, $game_variables[5])
    change_color(normal_color)
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105, y - 10 + 20 * 9, 120, 20, Vocab::param(7))
    change_color(normal_color)
    self.contents.font.color = Color.new(50,154,255)
    draw_text(x - 40, y - 10 + 20 * 9, 120, 20, $game_variables[18])
    change_color(normal_color)
    draw_text(x - 15, y - 10 + 20 * 9, 36, 20, actor.param(7), 2)
    change_color(normal_color)
    self.contents.font.color = Color.new(0,244,4)
    draw_text(x + 50, y - 10 + 20 * 9, 120, 20, $game_variables[6])
    change_color(normal_color)
 
    #equipment
 
    contents.font.size = 16
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105 , y + 30 + 16 * 10, 120, 16, "M. Hand")
    self.contents.font.color = Color.new(200,223,66)
    draw_text(x - 30, y +  + 30 + 16 * 10, 120, 16, $game_variables[57])
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105 , y + 30 + 16 * 11, 120, 16, "Offhand")
    self.contents.font.color = Color.new(200,223,66)
    draw_text(x - 30, y + 30 + 16 * 11, 120, 16, $game_variables[58])
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105 , y + 30 + 16 * 12, 120, 16, "Head")
    self.contents.font.color = Color.new(200,223,66)
    draw_text(x - 30, y + 30 + 16 * 12, 120, 16, $game_variables[56])
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105 , y + 30 + 16 * 13, 120, 16, "Body")
    self.contents.font.color = Color.new(200,223,66)
    draw_text(x - 30, y + 30 + 16 * 13, 120, 16, $game_variables[59])
 
    self.contents.font.color = Color.new(0,244,244)
    draw_text(x - 105 , y + 30 + 16 * 14, 120, 16, "accessory")
    self.contents.font.color = Color.new(200,223,66)
    draw_text(x - 30, y + 30 + 16 * 14, 120, 16, $game_variables[60])
 
  end
 
    #created a monster status display
 
 
  def draw_Monster_Status(target, x, y)
 
    contents.font.size = 20
 
    self.contents.font.color = Color.new(232, 4, 4)
 
    draw_text(x - 100, y - 15, 120, 20, $game_variables[218])
    change_color(normal_color)
 
    draw_text(x - 100, y - 15 + 20, 120, 20, Vocab::hp_a)
    change_color(normal_color)
 
    if $game_variables[201] * 100 / $game_variables[219] > 50
      self.contents.font.color = Color.new(4, 232, 4)
    end
 
    if $game_variables[201] * 100 / $game_variables[219] <= 50
      self.contents.font.color = Color.new(244,223,66)
    end
 
    if $game_variables[201] * 100 / $game_variables[219] <= 25
      self.contents.font.color = Color.new(244,4,4)
    end
 
    draw_text(x - 50, y - 15 + 20, 120, 20, $game_variables[201])
    change_color(normal_color)

 
    draw_text(x , y - 15 + 20, 120, 20, $game_variables[220])
    change_color(normal_color)
 
    draw_text(x - 100, y - 15 + 20 * 2, 120, 20, Vocab::param(2))
    change_color(normal_color)
 
    draw_text(x - 50, y - 15 + 20 * 2, 120, 20, $game_variables[203])
    change_color(normal_color)
 
    draw_text(x - 100, y - 15 + 20 * 3, 120, 20, Vocab::param(3))
    change_color(normal_color)
 
    draw_text(x - 50, y - 15 + 20 * 3, 120, 20, $game_variables[204])
    change_color(normal_color)

    draw_text(x - 100, y - 15 + 20 * 4, 120, 20, Vocab::param(4))
    change_color(normal_color)
 
    draw_text(x - 50, y - 15 + 20 * 4, 120, 20, $game_variables[205])
    change_color(normal_color)
 
    draw_text(x - 100, y - 15 + 20 * 5, 120, 20, Vocab::param(5))
    change_color(normal_color)
 
    draw_text(x - 50, y - 15 + 20 * 5, 120, 20, $game_variables[206])
    change_color(normal_color)
 
    draw_text(x - 100, y - 15 + 20 * 6, 120, 20, Vocab::param(6))
    change_color(normal_color)
 
    draw_text(x - 50, y - 15 + 20 * 6, 120, 20, $game_variables[207])
    change_color(normal_color)
 
    draw_text(x - 100, y - 15 + 20 * 7, 120, 20, Vocab::param(7))
    change_color(normal_color)
 
    draw_text(x - 50, y - 15 + 20 * 7, 120, 20, $game_variables[208])
    change_color(normal_color)
 
 
  end
 

  # not a status display; this is the scrolling message window

 
  def draw_actor_simple_status3(actor, x, y)
 
 
    contents.font.size = 12
          # adding parameters below
    change_color(normal_color)
    if $game_switches[26]
      self.contents.font.color = Color.new(244,4,4)
    end
    if $game_switches[36]
      self.contents.font.color = Color.new(4,244,4)
    end
    if $game_switches[46]
      self.contents.font.color = Color.new(244,244,4)
    end
    if $game_switches[56]
      self.contents.font.color = Color.new(244,4,244)
    end
    draw_text(x - 100, y - 25 + 0, Graphics.width, 12, $game_variables[126])
    change_color(normal_color)
 
    contents.font.size = 16
    if $game_switches[25]
      self.contents.font.color = Color.new(244,4,4)
    end
    if $game_switches[35]
      self.contents.font.color = Color.new(4,244,4)
    end
    if $game_switches[45]
      self.contents.font.color = Color.new(244,244,4)
    end
    if $game_switches[55]
      self.contents.font.color = Color.new(244,4,244)
    end
    draw_text(x - 100, y - 25 + 12, Graphics.width, 16, $game_variables[125])
    change_color(normal_color)

    contents.font.size = 20
    if $game_switches[24]
      self.contents.font.color = Color.new(244,4,4)
    end
    if $game_switches[34]
      self.contents.font.color = Color.new(4,244,4)
    end
    if $game_switches[44]
      self.contents.font.color = Color.new(244,244,4)
    end
    if $game_switches[54]
      self.contents.font.color = Color.new(244,4,244)
    end
    draw_text(x - 100, y - 25 + 28, Graphics.width, 20, $game_variables[124])
    change_color(normal_color)
 
    contents.font.size = 24
    if $game_switches[23]
      self.contents.font.color = Color.new(244,4,4)
    end
    if $game_switches[33]
      self.contents.font.color = Color.new(4,244,4)
    end
    if $game_switches[43]
      self.contents.font.color = Color.new(244,244,4)
    end
    if $game_switches[53]
      self.contents.font.color = Color.new(244,4,244)
    end
    draw_text(x - 100, y - 25 + 48, Graphics.width, 24, $game_variables[123])
    change_color(normal_color)

    contents.font.size = 28
    if $game_switches[22]
      self.contents.font.color = Color.new(244,4,4)
    end
    if $game_switches[32]
      self.contents.font.color = Color.new(4,244,4)
    end
    if $game_switches[42]
      self.contents.font.color = Color.new(244,244,4)
    end
    if $game_switches[52]
      self.contents.font.color = Color.new(244,4,244)
    end
    draw_text(x - 100, y - 25 + 72, Graphics.width, 28, $game_variables[122])
    change_color(normal_color)



 
  end

I'm certain the problem is in Map_Scene and will try Shaz's suggestions and attempt to figure that out now.

Thanks everyone!

EDITED heavily as requested to remove most superfluous code and make it easier to read.

I've moved this thread to Learning Ruby. Thank you.



RGSSx Scripts is for scripts you wish to release to the public that are finished.
why would you have window_base under materials?
First of all, put all ur code in code tag.
And you dont need to post the entire window_base code, just what you have modified.
I didn't read your code, as there's just too much there and it's formatted badly. So what I'm about to say is based on the assumption that you added code to call the refresh method in places where it previously wasn't.

Don't add a refresh call to any methods. Do what the current code does, and turn on a flag, then only refresh, in one spot, if that flag is on.

Do a global search needs_refresh, to see how it currently works.
Then add a new $game_map.needs_hud_refresh and turn it only only when the hud needs to be refreshed. In Game_Map, whenever it checks the needs_refresh flag, also make it check the needs_hud_refresh flag.
gstv87, simply because I had no idea what I was doing. As it is, I copied Window_Base and moved it down there because it's what worked. I'll go back and see if I can separate my specific code from it and see if I can get it to work like that. I have barely touched coding, just in the past two weeks and I've been handling everything I can with just events.

TheoAllen, What do you mean by code tag? You mean just tag it as #code in the bottom? It's been a long time since I've been on these forums, so I'm not up to speed on the etiquette.

Shaz, thanks! I'm going to try that later. What do you mean by, "It's formatted badly"? Is it just the way I posted my problem, the fact that I included superfluous code that doesn't involve my issue? Is there a way to post it so that it looks like it would in notepad++? Or is the code itself written in a terrible way that's going to come back to haunt me?

I really appreciate the help guys! (I know all three of you do some fantastic and sometimes overwhelming projects, so your taking the time to comment is really great) I'll try to clean up this post later and make it more decipherable in case I need to ask more questions.
@stickyka the code indentation will be broken and some of the characters will be turned into an emoticon
Code tag works like this
Code:
class Something
  def anything
    puts "everything"
  end
end
They keep the code indentation.

To use the code tag, use something like this.
Screenshot_401.jpg
I came back to my project after some time and figured this out thanks to the help of everyone in this thread.
I just needed to understand what @Shaz was explaining. By adding a trigger to the refresh command and setting that trigger
to specific times, it's able to refresh as needed as opposed to every frame. I really appreciate everyone taking their time to
explain things to me!

This thread can be closed.

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.

Original thread: https://forums.rpgmakerweb.com/threads/optimising-refresh-options.104651/