Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Displaying time in menu
Hoodlum
post Jan 15 2012, 10:45 AM
Post #1



Group Icon

Group: Member
Posts: 4
Type: Scripter
RM Skill: Beginner




I've made a mistake and posted this in a wrong section! Please, move this topic to RGSS2 Script Support.

Hello.
I am currently working on a game with a feature of displaying current game time in player's menu. It should be shown in a window, right above gold. I have wrote this script and called it Window_Time:
CODE
#==============================================================================
# ** Window_Time
#------------------------------------------------------------------------------
#  This window displays playtime on the menu screen.
#==============================================================================

class Window_Time < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y)
   super(x, y, 160, WLH * 3)
   refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @time = Graphics.frame_count / Graphics.frame_rate
    hour = @time / 60 / 60
    min = @time / 60 % 60
    sec = @time % 60
    text = sprintf("Game time: %dh:%dmin", hour, min, sec)
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 120, self.height / 2, text, 1)
  end
end

Next, I've added this line in Scene_Menu:
CODE
@time_window = Window_Time.new(0, 248)

Now when I press ESC in game, the window with text 'Game time: 0h:0min" is shown for a second and then it just disappears... How to make it work? Thanks in advance for any answers!

This post has been edited by Hoodlum: Jan 15 2012, 10:47 AM
Go to the top of the page
 
+Quote Post
   
The Law G14
post Jan 15 2012, 10:52 AM
Post #2


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5




Hey, I'll move this topic for you smile.gif

Also, in the terminate method of Scene_Menu, make sure you add:

CODE
@time_window.dispose


and in the update method, also add:

CODE
@time_window.update


I'm not sure if this will fix your problem, but we can start from there smile.gif


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
Hoodlum
post Jan 15 2012, 10:58 AM
Post #3



Group Icon

Group: Member
Posts: 4
Type: Scripter
RM Skill: Beginner




Thanks for your very fast reaction!
I've tried it and reult is the same - the window disappears very fast. Also, after closing the menu, game crashes with following error:
CODE
Script 'Window_Base' line 37: RGSSError occurred.
disposed window

Line 37 is here:
CODE
  def dispose
    self.contents.dispose # Line 37
    super
  end

Hmm, any other ideas?

This post has been edited by Hoodlum: Jan 15 2012, 10:58 AM
Go to the top of the page
 
+Quote Post
   
The Law G14
post Jan 15 2012, 12:09 PM
Post #4


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5




Hm, this is very weird, I tried putting the script in my game and I don't get any such errors, do you have any other custom scripts in your game?


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
The Law G14
post Jan 15 2012, 12:09 PM
Post #5


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5




Hm, this is very weird, I tried putting the script in my game and I don't get any such errors, do you have any other custom scripts in your game?


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
Hoodlum
post Jan 15 2012, 12:37 PM
Post #6



Group Icon

Group: Member
Posts: 4
Type: Scripter
RM Skill: Beginner




Yes, it seems that Jet's Time System is ruining everything... It's a shame, 'cause I really like this script and can't find anything in advantage. Well, anyway, thanks for your help, there is no problem anymore, although if someone knows how to make it work with Jet's Time System it would be really great. tongue.gif
Go to the top of the page
 
+Quote Post
   
The Law G14
post Jan 15 2012, 01:46 PM
Post #7


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5




I can try to get them to work together if you'd like smile.gif Just send me Jet's Time System, do you have any other custom scripts?


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
Hoodlum
post Jan 15 2012, 05:02 PM
Post #8



Group Icon

Group: Member
Posts: 4
Type: Scripter
RM Skill: Beginner




I wasn't expecting such helpfulness, it makes me nicely surprised (in Poland, where I live, it would be hard to find someone like you tongue.gif)! Again thank you very much, but this time I need to refuse - I don't want to bother you with it, since it surely would take some amount of time. Also I would wish to learn RGSS by fixing most of the problems myself. I am advanced scripter in Pawn language (used in GTA: San Andreas Multiplayer) and I know how to think like programmer if you know what I mean. ;d I don't read any tutorials, just look at code, analyze it and try to change it for my needs. So I've removed Jet's Time System and replaced it with my own, based on events and few commands in Game_Interpreter class. The window now works and I've even managed to draw an hourglass icon next to the time amount! biggrin.gif
Go to the top of the page
 
+Quote Post
   
The Law G14
post Jan 15 2012, 06:07 PM
Post #9


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5




Great, I'm glad it's all working for you! And thanks for the compliment lol, if you need any later help in scripting, throw me a PM and I'll be more than happy to help you out (Though it seems you're already progressing very well biggrin.gif )


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th May 2013 - 10:34 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker