How to draw save-file temp in-game?

Sorry for my bad English, i'm Brazilian.

My question is: How do I draw the currente save game time in a window?
game play time or file creation date?
game play time or file creation date?
Gameplay time.
find window_savefile, line 25 and 47
find window_savefile, line 25 and 47
I made this. I copied and pasted the "draw_playtime" method to my scene, but nothing happened.
Oh no. I found the lines you said, I will test.
...Nothing happened.

My code:

Ruby:
module AddVar # Módulo de configuração.
  ICONE = 467
  BACKG_OPACITY = 160
end

class Scene_AddVar < Scene_Base
  def start
    super
    
    @window_add_var = Window_AddVar.new(0,0,100,50) # Criando a janela.
    
    @window_add_var.z = 300 # Alterando valor "z", que faz a janela ficar por cima.
        
    @window_add_var.draw_text_ex(2, 2, $game_party.steps) # Criando o texto.
    
    @window_add_var.draw_icon(AddVar::ICONE, 50, 0) # Criando o ícone.
    
    create_background # Criando o background (plano de fundo).
    
    @window_add_var.draw_playtime(0, 50 - 25, 50 - 4, 2)
  end
 
  def update
    super
    if Input.trigger?(:DOWN) # Se, enquanto estiver na janela, apertar para baixo, a janela sai.
      return_scene # Retorna a scene (cena), ou seja, faz a janela sair.
    end
  end
 
  def create_background # Método de criação do background.
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(0, 0, 0, AddVar::BACKG_OPACITY)
  end
end

class Window_AddVar < Window_Base # Criando a janela.
  def initialize(x, y, width, height)
    super
    self.opacity = 180 # Opacidade da janela. Não é muito importante alterar essa opacidade.
  end
 
  def draw_playtime(x, y, width, align)
    header = DataManager.load_header(@file_index)
    return unless header
    draw_text(x, y, width, line_height, header[:playtime_s], 2)
  end
end
replace the header[playtime] bit with a random string, just to force the draw_text to validate.
if nothing shows up, replace the 2 at the end with a 0... if it draws the text, then the width of the block is too large and the text is being drawn off screen.

since you're not getting any errors, then the draw text is either not being called (which implies the header is not being loaded), or is being drawn but off screen.

if nothing happens at all, we'll take it from there.
but first, validate that call.
Nothing happened:

Ruby:
module AddVar # Módulo de configuração.
  ICONE = 467
  BACKG_OPACITY = 160
end

class Scene_AddVar < Scene_Base
  def start
    super
    
    @window_add_var = Window_AddVar.new(0,0,350,350) # Criando a janela.
    
    @window_add_var.z = 300 # Alterando valor "z", que faz a janela ficar por cima.
        
    @window_add_var.draw_text_ex(2, 2, $game_party.steps) # Criando o texto.
    
    @window_add_var.draw_icon(AddVar::ICONE, 50, 0) # Criando o ícone.
    
    draw_playtime(0, 40 - 20, 20 - 4, 0) if Input.trigger?(:LEFT)

    create_background # Criando o background (plano de fundo).
  end
 
  def update
    super
    if Input.trigger?(:DOWN) # Se, enquanto estiver na janela, apertar para baixo, a janela sai.
      return_scene # Retorna a scene (cena), ou seja, faz a janela sair.
    end
  end
 
  def create_background # Método de criação do background.
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(0, 0, 0, AddVar::BACKG_OPACITY)
  end
end

class Window_AddVar < Window_Base # Criando a janela.
  def initialize(x, y, width, height)
    super
    self.opacity = 180 # Opacidade da janela. Não é muito importante alterar essa opacidade.
  end
 
  def draw_playtime(x, y, width, align)
    davi = DataManager.load_header(@file_index)
    return unless davi
    draw_text(x, y, width, line_height, davi[:saveve], 0)
    
    p davi[:saveve]
  end
end

class Scene_Map < Scene_Base
 
  alias adk_start start
 
  def start
    adk_start
    SceneManager.call(Scene_AddVar)
  end
end
Code:
p davi[:saveve]

does this print out?
if it does then that block is working, because the core of the matter is loading the data from the data manager, which triggers that block.
in order to pull the data from the save, you just need data.load_header(index), and that's it.
if that doesn't fail and doesn't throw an error message, then the drawing text bit is failing, or being rendered out of view.
No, no printed nothing in console.
then that block isn't running.
that's your answer to why "it's not showing up".

Code:
davi = DataManager.load_header(@file_index)
check *that* line and put the print right below it.
if it works, then validate the rest.
if not, then there's something wrong with the file.
Ruby:
class Window_AddVar < Window_Base # Criando a janela.
  def initialize(x, y, width, height)
    super
    self.opacity = 180 # Opacidade da janela. Não é muito importante alterar essa opacidade.
  end

  def draw_playtime(x, y, width, align)
    davi = DataManager.load_header(@file_index)
    p davi[:saveve]
    return unless davi
    draw_text(x, y, width, line_height, davi[:saveve], 0)
  end
end

No, still not printing on the console... 🙁

I will test it on a new project, it could be wrong.

EDIT: In the other project didn't work either...
Oh! I did the old way.

I got the code from Window Save File, pasted it and commented until I found the source of the error which was what was doing so the code didn't appear and ... I FIND IT!

The error:
To work, I needed the following line of code:
Ruby:
  def initialize(height, index)
    super(0, index * height, Graphics.width, height)
    @file_index = index # <-- for this and...
    refresh # <--- ...this
#~     @selected = false
  end
  #--------------------------------------------------------------------------
  # * Renovação
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
#~     change_color(normal_color)
#~     name = Vocab::File + " #{@file_index + 1}"
#~     draw_text(4, 0, 200, line_height, name)
#~     @name_width = text_size(name).width
#~     draw_party_characters(152, 58)
    draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
  end
Just use this: $game_system.playtime_s
Just use this: $game_system.playtime_s
Eu já usei, Gabriel.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-draw-save-file-temp-in-game.120884/