Polloyus

Villager
Member
Joined
Apr 30, 2020
Messages
15
Reaction score
2
First Language
Portuguese-BR.
Primarily Uses
RMVXA
Sorry for my bad English, i'm Brazilian.

My question is: How do I draw the currente save game time in a window?
 

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,269
Reaction score
2,441
First Language
Spanish
Primarily Uses
RMVXA
game play time or file creation date?
 

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,269
Reaction score
2,441
First Language
Spanish
Primarily Uses
RMVXA
find window_savefile, line 25 and 47
 

Polloyus

Villager
Member
Joined
Apr 30, 2020
Messages
15
Reaction score
2
First Language
Portuguese-BR.
Primarily Uses
RMVXA
find window_savefile, line 25 and 47
I made this. I copied and pasted the "draw_playtime" method to my scene, but nothing happened.
 

Polloyus

Villager
Member
Joined
Apr 30, 2020
Messages
15
Reaction score
2
First Language
Portuguese-BR.
Primarily Uses
RMVXA
Oh no. I found the lines you said, I will test.
 

Polloyus

Villager
Member
Joined
Apr 30, 2020
Messages
15
Reaction score
2
First Language
Portuguese-BR.
Primarily Uses
RMVXA
...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
 

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,269
Reaction score
2,441
First Language
Spanish
Primarily Uses
RMVXA
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.
 

Polloyus

Villager
Member
Joined
Apr 30, 2020
Messages
15
Reaction score
2
First Language
Portuguese-BR.
Primarily Uses
RMVXA
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
 

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,269
Reaction score
2,441
First Language
Spanish
Primarily Uses
RMVXA
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.
 

Polloyus

Villager
Member
Joined
Apr 30, 2020
Messages
15
Reaction score
2
First Language
Portuguese-BR.
Primarily Uses
RMVXA
No, no printed nothing in console.
 

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,269
Reaction score
2,441
First Language
Spanish
Primarily Uses
RMVXA
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.
 

Polloyus

Villager
Member
Joined
Apr 30, 2020
Messages
15
Reaction score
2
First Language
Portuguese-BR.
Primarily Uses
RMVXA
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...
 
Last edited:

Polloyus

Villager
Member
Joined
Apr 30, 2020
Messages
15
Reaction score
2
First Language
Portuguese-BR.
Primarily Uses
RMVXA
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
 

Gabe

Gabriel
Regular
Joined
Sep 4, 2017
Messages
76
Reaction score
236
First Language
Portuguese (BR)
Primarily Uses
RMMZ
Just use this: $game_system.playtime_s
 

Latest Threads

Latest Profile Posts

Maybe it's just me...but it feels like everyone else has perfectly normal and respectable game threads except for me and @TESTOSTERONE, whose threads are a mess of discussions and jokes with very little relation to our actual games.
Do I... do I just release the demo as one quest line?
"Now that I called the advent calendar done I won't work on it anymore" and other jokes I tell myself...
I lowk am stuck with ideas on Crimson Prelude, cause I got the general idea of the follow-up Evangelist, but prelude is a tricky one, plus the final fantasy project, I need to release something though.

I might just whip up a story real quick and make a high quality game as my first project and push these to the side.

Maybe a gacha rpg xd.......YES

Forum statistics

Threads
134,822
Messages
1,250,958
Members
177,619
Latest member
SolidGent91
Top