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
> Very Simple Question, I'm a script newb, just need a little help.
superafroboy
post Oct 15 2011, 07:12 AM
Post #1


Level 3
Group Icon

Group: Member
Posts: 39
Type: None
RM Skill: Skilled




Hey guys, I have next to no knowledge of scripting, and just wanted to make a quick little script that displays the current date after my hero rests / checks the calendar.

I have everything set up, but I don't know how to display the window only for a few seconds, and then remove it.

Currently it just displays for a short time and then is removed on its own (I assume after something is refreshed or whatever?)

Here is my pathetic little script, I assume there is something I could just throw in at the end to dispose the window after x frames or something?

CODE
class Calendar < Window_Base
  def initialize
    super(0, 0, 200, 120)
    self.contents = Bitmap.new(width - 32, height - 32)

    date = $game_variables[4]
    year = $game_variables[9]
    
    if $game_variables[18] == 1
      weekday = "Monday"
    elsif $game_variables[18] == 2
      weekday = "Tuesday"
    elsif $game_variables[18] == 3
      weekday = "Wednesday"
    elsif $game_variables[18] == 4
      weekday = "Thursday"
    elsif $game_variables[18] == 5
      weekday = "Friday"
    elsif $game_variables[18] == 6
      weekday = "Holiday"
    else
      weekday = "Nil"
    end    


   self.contents.font.size = 20
   self.contents.draw_text(0, 0, 200, 32, "Today's Date is:")
   self.contents.draw_text(0, 20, 200, 32, weekday)
   self.contents.draw_text(0, 40, 30, 32, "Day")
   self.contents.draw_text(35, 40, 25, 32, date.to_s)
   self.contents.draw_text(0, 60, 40, 32, "Year")
   self.contents.draw_text(45, 60, 25, 32, year.to_s)
  
  end

end



Any help would be much appreciated.

This post has been edited by superafroboy: Oct 15 2011, 07:14 AM


__________________________
Go to the top of the page
 
+Quote Post
   
maximusmaxy
post Oct 15 2011, 08:28 AM
Post #2


PZE whore
Group Icon

Group: Revolutionary
Posts: 131
Type: Scripter
RM Skill: Skilled




QUOTE (superafroboy @ Oct 16 2011, 02:12 AM) *
Hey guys, I have next to no knowledge of scripting, and just wanted to make a quick little script that displays the current date after my hero rests / checks the calendar.

I have everything set up, but I don't know how to display the window only for a few seconds, and then remove it.

Currently it just displays for a short time and then is removed on its own (I assume after something is refreshed or whatever?)

Here is my pathetic little script, I assume there is something I could just throw in at the end to dispose the window after x frames or something?

CODE
class Calendar < Window_Base
  def initialize
    super(0, 0, 200, 120)
    self.contents = Bitmap.new(width - 32, height - 32)

    date = $game_variables[4]
    year = $game_variables[9]
    
    if $game_variables[18] == 1
      weekday = "Monday"
    elsif $game_variables[18] == 2
      weekday = "Tuesday"
    elsif $game_variables[18] == 3
      weekday = "Wednesday"
    elsif $game_variables[18] == 4
      weekday = "Thursday"
    elsif $game_variables[18] == 5
      weekday = "Friday"
    elsif $game_variables[18] == 6
      weekday = "Holiday"
    else
      weekday = "Nil"
    end    


   self.contents.font.size = 20
   self.contents.draw_text(0, 0, 200, 32, "Today's Date is:")
   self.contents.draw_text(0, 20, 200, 32, weekday)
   self.contents.draw_text(0, 40, 30, 32, "Day")
   self.contents.draw_text(35, 40, 25, 32, date.to_s)
   self.contents.draw_text(0, 60, 40, 32, "Year")
   self.contents.draw_text(45, 60, 25, 32, year.to_s)
  
  end

end



Any help would be much appreciated.


Try this out.
CODE
#Set the amount of frames the calendar is shown here
CALENDAR_COUNT = 80

#===============================================================================
# Calendar
#===============================================================================

class Calendar < Window_Base
  def initialize
    super(0, 0, 200, 120)
    self.contents = Bitmap.new(width - 32, height - 32)

    date = $game_variables[4]
    year = $game_variables[9]
    
    if $game_variables[18] == 1
      weekday = "Monday"
    elsif $game_variables[18] == 2
      weekday = "Tuesday"
    elsif $game_variables[18] == 3
      weekday = "Wednesday"
    elsif $game_variables[18] == 4
      weekday = "Thursday"
    elsif $game_variables[18] == 5
      weekday = "Friday"
    elsif $game_variables[18] == 6
      weekday = "Holiday"
    else
      weekday = "Nil"
    end    

    self.contents.font.size = 20
    self.contents.draw_text(0, 0, 200, 32, "Today's Date is:")
    self.contents.draw_text(0, 20, 200, 32, weekday)
    self.contents.draw_text(0, 40, 30, 32, "Day")
    self.contents.draw_text(35, 40, 25, 32, date.to_s)
    self.contents.draw_text(0, 60, 40, 32, "Year")
    self.contents.draw_text(45, 60, 25, 32, year.to_s)
    #variable to keep track of how long the window has been displayed
    @count = 0
  end
  
  def update
    #increment the count
    @count += 1
    #stop showing window when count reaches maximum
    $game_temp.show_calendar = false if @count == CALENDAR_COUNT
  end
end

#===============================================================================
# Game_Temp
#===============================================================================

class Game_Temp
  attr_accessor :show_calendar
  alias max_calendar_initialize_later initialize
  def initialize
    #run the old initialize method
    max_calendar_initialize_later
    #temp variable to flag the calendar to be shown
    @show_calendar = false
  end
end

#===============================================================================
# Scene_Map
#===============================================================================

class Scene_Map
  alias max_calendar_update_later update
  alias max_calendar_main_later main
  def main
    #run the old main method
    max_calendar_main_later
    #dispose calendar if it exists
    @calendar.dispose unless @calendar.nil?
  end
  
  def update
    #run the old update method
    max_calendar_update_later
    #if the calendar is flagged to be shown
    if $game_temp.show_calendar
      #create the calendar if it hasn't been created
      @calendar = Calendar.new if @calendar.nil?
      #update the calendar
      @calendar.update
    #if the calendar exists and calendar isn't flagged to be shown
    elsif !@calendar.nil?
      #dispose the calendar
      @calendar.dispose
      @calendar = nil
    end
  end
end

Choose how many frames you want it to be displayed by setting the CALENDAR_COUNT variable at the top. To display the calendar just use this call script:
CODE
$game_temp.show_calendar = true


__________________________
Check out the new PZE Forums! http://zeldaengine.net/index.php
Go to the top of the page
 
+Quote Post
   
superafroboy
post Oct 15 2011, 08:35 AM
Post #3


Level 3
Group Icon

Group: Member
Posts: 39
Type: None
RM Skill: Skilled




Works perfectly, thank you very much!


__________________________
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: 18th May 2013 - 07:21 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker