设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1599|回复: 8
打印 上一主题 下一主题

[已经解决] Advanced Game Time + Night/Day v1.4.2的时间控制

[复制链接]

Lv1.梦旅人

梦石
0
星屑
155
在线时间
129 小时
注册时间
2014-2-22
帖子
233
跳转到指定楼层
1
发表于 2014-3-15 16:37:39 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 Sion 于 2014-3-16 19:19 编辑

各位大神,又来麻烦了!
我前几天在论坛上搜时间的脚本,发现了标题这个看起来还不错的脚本,不过可惜是英文的。我用了之后发现,当我想做一个周期的事件的时候,我没办法知道现在是什么时间,但是他有一个地图显示时间的框,但是我不会获取,求各位大神再次帮忙……
脚本在这里:
RUBY 代码复制
  1. <P>#Advanced Game Time + Night/Day v1.4.2
  2. #----------#
  3. #Features: Provides a series of functions to set and recall current game time
  4. #          as well customizable tints based on current game time to give the
  5. #          appearance of night and day in an advanced and customizable way.
  6. #
  7. #Usage:   Script calls:
  8. #           GameTime.sec?                      #current second
  9. #           GameTime.min?                      #current minute
  10. #           GameTime.hour?                     #current hour
  11. #           GameTime.hour_nom?                 #current hour (12-hour)
  12. #           GameTime.day?                      #current day of month
  13. #           GameTime.day_week?                 #current day of the week
  14. #           GameTime.day_year?                 #current day of the year
  15. #           GameTime.month?                    #current month
  16. #           GameTime.year?                     #current year
  17. #           GameTime.year_post("set")          #changes the year post to set
  18. #           GameTime.pause_tint(true/false)    #pauses/unpauses tint
  19. #           GameTime.notime(true/false)        #stops time based on true/false
  20. #           GameTime.change(s,m,h,d,dw,mn,y)      #manually set the time
  21. #                                    seconds,minutes,hours,days,weekday,months,years
  22. #                                              any can be nil to not be changed
  23. #           GameTime.set("handle",n)           #increases a certain time portion
  24. #                                             valid arguments are:
  25. #                                               addsec,addmin,addhour,addday
  26. #                                               addmonth,addyear
  27. #                                             and:
  28. #                                               remsec,remmin,remhour,remday
  29. #                                               remmonth,remyear
  30. #           GameTime.clock?(true/false)        #hides/shows the clock
  31. #           GameTime.save_time                 #saves the current time
  32. #           GameTime.load_time                 #loads the saved time
  33. #
  34. #         Message Codes:
  35. #           GTSEC    #Inputs the current second
  36. #           GTMIN    #Inputs the current minute
  37. #           GTHOUR   #Inputs the current hour
  38. #           GTDAYN   #Inputs the day of the month
  39. #           GTDAYF   #Inputs the day of the week (full)
  40. #           GTDAYA   #Inputs the day of the week (abbreviated)
  41. #           GTMONN   #Inputs the month of the year
  42. #           GTMONF   #Inputs the name of the month (full)
  43. #           GTMONA   #Inputs the name of the month (abbreviated)
  44. #           GTYEAR   #Inputs the current year
  45. #
  46. #         Map Note Tags: (These go in the note box of Map Properties)
  47. #           Notint   #These maps will not tint!
  48. #           Notime   #Stops time from moving in that map
  49. #        
  50. #Customization: Set below, in comments.
  51. #
  52. #Examples: GameTime.pause_tint = false
  53. #          GameTime.change(nil,30,4,1,1,1,2012)
  54. #          GameTime.set("addyear",5)
  55. #          GameTime.clock?(true)
  56. #
  57. #----------#
  58. #-- Script by: V.M of D.T
  59. #
  60. #- Questions or comments can be:
  61. #    posted on the thread for the script
  62. #    given by email: <A href="mailto:[email protected]">[email protected]</A>
  63. #    provided on facebook: <A href="http://www.facebook.com/DaimoniousTailsGames">http://www.facebook.com/DaimoniousTailsGames</A>
  64. #    posed on site: daimonioustails.wordpress.com
  65. #
  66. #--- Free to use in any non-commercial project with credit given
  67. #-- License required for commercial project use</P>
  68. <P>#_# BEGIN_CUSTOMIZATION #_#</P>
  69. <P>
  70. #What time a new game starts at: [sec, min, hour, day, month, year]
  71. START_TIME = [0,0,0,0,0,0]
  72. #Wether or not to set time to PC (Real) Time
  73. USE_REAL_TIME = false
  74. #Time does not increase while the message window is visible:
  75. NOTIMEMESSAGE = false
  76. #Time does not increase unless you are on the map
  77. PAUSE_IN_MENUS = true
  78. #Time does not increase if you are in battle
  79. NOBATTLETIME = false
  80. #Clock is shown
  81. USECLOCK = true
  82. #Set to true to have the clock show up in the menu!
  83. USECLOCK_MENU = true
  84. #Set the format for the clock both in and out of menu
  85. #1. hh:mm am/pm
  86. #2. Sun dd hh:mm am/pm
  87. #3. hh:mm        (24 hour clock)
  88. #4. Sun dd hh:mm (24 hour clock)
  89. #5. Custom clock, see below
  90. CLOCK_FORMAT = 5
  91. MENU_CLOCK_FORMAT = 5
  92. #Clock window background opacity
  93. CLOCK_BACK = 255
  94. #Button to be used to toggle the clock
  95. CLOCK_TOGGLE = :SHIFT
  96. #X and Y position of clock
  97. CLOCK_X = 0
  98. CLOCK_Y = 0
  99. #Finetune the width of the clock window here:
  100. CLOCK_WIDTH = 175
  101. #Whether or not those little dots on the clock blink
  102. USE_BLINK = true
  103. #The speed at which they blink
  104. BLINK_SPEED = 120
  105. #Here is where you would insert the array of commands for the custom clock:
  106. CUSTOM_CLOCK = ["weekshort"," ","day"," ","year","yearp"]
  107. CUSTOM_CLOCK2 = ["hour12","blinky","min"," ","meri"]
  108. #Available commands for CUSTOM_CLOCK:
  109. # "sec" - seconds         "min" - minutes
  110. # "hour" - hour (24)      "hour12" - hour (12)
  111. # "meri" - AM/PM          "day" - day of the month
  112. # "weekshort" - day of the week abbr
  113. # "weeklong" - day of the week long
  114. # "month" - month         "monthshort" - month name abbr
  115. # "monthlong" - month name
  116. # "year" - year           "yearp" - year post
  117. # "blinky" - those blinky dots</P>
  118. <P>
  119. #Using KHAS lighting effects script? Turn this on to use that tint
  120. USE_KHAS = true
  121. #Using Victor Engine Light effects? Turn this on to use that tint
  122. USE_VICTOR = true
  123. #Variables that count down each gametime second/minute
  124. TIMER_VARIABLES = []</P>
  125. <P>#Use Tint in the Battles
  126. BATTLE_TINT = false</P>
  127. <P>#Time it takes for a second (or minute) to pass, in frames by default
  128. #(Frame rate is 60 frames per second)
  129. DEFAULT_TIMELAPSE = 60
  130. #Variable ID containing the current speed of time!
  131. TIMELAPSE_VARIABLE = 80
  132. #Whether to use seconds or not
  133. NOSECONDS = true
  134. #Number of seconds in a minute
  135. SECONDSINMIN = 60
  136. #Number of minutes in an hour
  137. MINUTESINHOUR = 60
  138. #Number of hours in a day
  139. HOURSINDAY = 24
  140. #Names of the days (As little or as many days in the week as you want)
  141. DAYNAMES = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
  142. #Day name abbreviations
  143. DAYNAMESABBR = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
  144. #Number of days in each month (Also represents number of months in a year)
  145. MONTHS = [31,28,31,30,31,30,31,31,30,31,30,31]
  146. #Names of the months
  147. MONTHNAMES = ["January","February","March","April","May","June",
  148.               "July","August","September","October","November","December"]
  149. #Abrreviated names of the months
  150. MONTHNAMESABBR = ["Jan","Feb","Mar","Apr","May","Jun",
  151.                   "Jul","Aug","Sep","Oct","Nov","Dec"]
  152. #The default letters to be posted before the year in dates
  153. DEFAULT_YEAR_POST = "AD"
  154. #NOT YET IMPLEMENTED *IGNORE*
  155. USE_PERIODS = true
  156.  
  157. #Gradual tint effects! (The hardest part)
  158. #It may look daunting, and it is, but here is where you put the tint
  159. #to be shown at each hour (the actual tint is usually somewhere in between)
  160. #The number of Color.new objects here must equal the number of hours in a day
  161. #Starts from hour 0 (or 12am)
  162. #A color object is -> Color.new(r,g,b,a)
  163. # Where r is red,g is green,b is blue,and a is opacity and all are (0-255)
  164. TINTS = [Color.new(30,0,40,155),
  165.          Color.new(20,0,30,135),
  166.          Color.new(20,0,30,135),
  167.          Color.new(10,0,30,135),
  168.          Color.new(10,0,20,125),
  169.          Color.new(0,0,20,125),
  170.          Color.new(80,20,20,125),
  171.          Color.new(130,40,10,105),
  172.          Color.new(80,20,10,85),
  173.          Color.new(0,0,0,65),
  174.          Color.new(0,0,0,35),
  175.          Color.new(0,0,0,15),
  176.          Color.new(0,0,0,0),
  177.          Color.new(0,0,0,0),
  178.          Color.new(0,0,0,5),
  179.          Color.new(0,0,0,15),
  180.          Color.new(0,0,0,25),
  181.          Color.new(0,0,10,55),
  182.          Color.new(80,20,20,85),
  183.          Color.new(130,40,30,105),
  184.          Color.new(80,20,40,125),
  185.          Color.new(10,0,50,135),
  186.          Color.new(20,0,60,135),
  187.          Color.new(30,0,70,155)]</P>
  188. <P>#NOT YET IMPLEMENTED *IGNORE*
  189. PERIODS = [["Night",0,5],
  190.            ["Morning",6,11],
  191.            ["Afternoon",12,17],
  192.            ["Evening",18,23]]
  193.  
  194. $gametimeclockvisible = true
  195. #_# END CUSTOMIZATION #_#
  196.  
  197. module GameTime
  198.   def self.run
  199.     $game_time = Current_Time.new
  200.     $game_time_tint = Sprite_TimeTint.new
  201.   end
  202.   def self.update
  203.     return if $game_message.busy? and NOTIMEMESSAGE
  204.     if !SceneManager.scene.is_a?(Scene_Map) and PAUSE_IN_MENUS
  205.       return $game_time_tint.update if SceneManager.scene.is_a?(Scene_Title)
  206.       return $game_time_tint.update if SceneManager.scene.is_a?(Scene_File)
  207.       return unless SceneManager.scene.is_a?(Scene_Battle) and !NOBATTLETIME
  208.     end
  209.     $game_time.update
  210.     $game_time_tint = Sprite_TimeTint.new if $game_time_tint.disposed?
  211.     update_tint
  212.   end
  213.   def self.update_tint
  214.     $game_time_tint.update unless @pause_tint
  215.   end
  216.   def self.sec?
  217.     return $game_time.sec
  218.   end
  219.   def self.min?
  220.     return $game_time.min
  221.   end
  222.   def self.hour?
  223.     return $game_time.hour
  224.   end
  225.   def self.hour_nom?
  226.     hour = $game_time.hour
  227.     hour -= 12 if hour > 11
  228.     hour = 12 if hour == 0
  229.     return hour
  230.   end
  231.   def self.day?
  232.     return $game_time.day if USE_REAL_TIME
  233.     return $game_time.day + 1
  234.   end
  235.   def self.day_week?
  236.     return $game_time.dayweek
  237.   end
  238.   def self.day_year?
  239.     month = month? - 1
  240.     day = day?
  241.     while month > 0
  242.       day += MONTHS[month]
  243.       month -= 1
  244.     end
  245.     day
  246.   end
  247.   def self.day_name
  248.     return DAYNAMES[$game_time.dayweek-1] if USE_REAL_TIME
  249.     return DAYNAMES[$game_time.dayweek]
  250.   end
  251.   def self.day_name_abbr
  252.     return DAYNAMESABBR[$game_time.dayweek-1] if USE_REAL_TIME
  253.     return DAYNAMESABBR[$game_time.dayweek]
  254.   end
  255.   def self.month_name_abbr
  256.     return MONTHNAMESABBR[$game_time.month-1] if USE_REAL_TIME
  257.     return MONTHNAMESABBR[$game_time.month]
  258.   end
  259.   def self.month?
  260.     return $game_time.month if USE_REAL_TIME
  261.     return $game_time.month + 1
  262.   end
  263.   def self.month_name
  264.     return MONTHNAMES[$game_time.month-1] if USE_REAL_TIME
  265.     return MONTHNAMES[$game_time.month]
  266.   end
  267.   def self.year?
  268.     return $game_time.year
  269.   end
  270.   def self.pause_tint(set)
  271.     @pause_tint = set
  272.   end
  273.   def self.change(s = nil,m = nil,h = nil,d = nil,dw = nil, mn = nil,y = nil)
  274.     $game_time.manual(s,m,h,d,dw,mn,y)
  275.   end
  276.   def self.set(handle,n)
  277.     $game_time.forward(handle,n)
  278.   end
  279.   def self.clock?(set)
  280.     SceneManager.scene.clock_visible?(set)
  281.   end
  282.   def self.year_post(set)
  283.     $game_time.year_post = set
  284.   end
  285.   def self.save_time
  286.     $saved_game_time = $game_time.dup
  287.   end
  288.   def self.load_time
  289.     $game_time = $saved_game_time.dup
  290.   end
  291.   def self.no_time_map
  292.     note = $game_map.map_note
  293.     /Notime/ =~ note
  294.     return false unless $~
  295.     return true
  296.   end
  297.   def self.notime(set)
  298.     $game_time.notime = set
  299.   end</P>
  300. <P>  class Current_Time
  301.  
  302.     attr_reader     :sec
  303.     attr_reader     :min
  304.     attr_reader     :hour
  305.     attr_reader     :day
  306.     attr_reader     :dayweek
  307.     attr_reader     :month
  308.     attr_reader     :year
  309.     attr_accessor   :year_post
  310.     attr_accessor   :notime
  311.  
  312.     def initialize
  313.       reset_all_values
  314.     end
  315.     def reset_all_values
  316.       @sec = START_TIME[0]
  317.       [url=home.php?mod=space&uid=25749]@min[/url] = START_TIME[1]
  318.       @hour = START_TIME[2]
  319.       [url=home.php?mod=space&uid=11519]@day[/url] = START_TIME[3]
  320.       @dayweek = 0
  321.       [url=home.php?mod=space&uid=26122]@Month[/url] = START_TIME[4]
  322.       @year = START_TIME[5]
  323.       @notime = false
  324.       @year_post = DEFAULT_YEAR_POST
  325.     end
  326.     def update
  327.       return realtime if USE_REAL_TIME
  328.       return if GameTime.no_time_map or @notime
  329.       $game_variables[TIMELAPSE_VARIABLE] = DEFAULT_TIMELAPSE if $game_variables[TIMELAPSE_VARIABLE] <= 0
  330.       return unless Graphics.frame_count % $game_variables[TIMELAPSE_VARIABLE] == 0
  331.       NOSECONDS ? addmin(1) : addsec(1)
  332.       update_timers
  333.     end
  334.     def update_timers
  335.       return unless TIMER_VARIABLES.size > 0
  336.       for i in TIMER_VARIABLES
  337.         $game_variables[i] -= 1 unless $game_variables[i] == 0
  338.       end
  339.     end
  340.     def realtime
  341.       @sec = Time.now.sec
  342.       @sec = 0 if @sec == 60
  343.       [url=home.php?mod=space&uid=25749]@min[/url] = Time.now.min
  344.       @hour = Time.now.hour
  345.       [url=home.php?mod=space&uid=11519]@day[/url] = Time.now.day
  346.       @dayweek = Time.now.wday
  347.       [url=home.php?mod=space&uid=26122]@Month[/url] = Time.now.month
  348.       @year = Time.now.year
  349.       0
  350.     end
  351.     def addsec(s)
  352.       @sec += s
  353.       return unless @sec == SECONDSINMIN
  354.       @sec = 0
  355.       addmin(1)
  356.     end
  357.     def addmin(m)
  358.       @min += m
  359.       return unless @min == MINUTESINHOUR
  360.       @min = 0
  361.       addhour(1)
  362.     end
  363.     def addhour(h)
  364.       @hour += h
  365.       return unless @hour == HOURSINDAY
  366.       @hour = 0
  367.       addday(1)
  368.     end
  369.     def addday(d)
  370.       @day += d
  371.       @dayweek += d
  372.       @dayweek = 0 if @dayweek == DAYNAMES.size
  373.       return unless @day == MONTHS[@month]
  374.       @day = 0
  375.       addmonth(1)
  376.     end
  377.     def addmonth(mn)
  378.       @month += mn
  379.       return unless @month == MONTHS.size
  380.       @month = 0
  381.       addyear(1)
  382.     end
  383.     def addyear(y)
  384.       @year += y
  385.     end
  386.     def manual(s = nil,m = nil,h = nil,d = nil,dw = nil,mn = nil,y = nil)
  387.       @sec = s if !s.nil?
  388.       @sec = SECONDSINMIN - 1 if @sec >= SECONDSINMIN
  389.       @min = m if !m.nil?
  390.       @min = MINUTESINHOUR - 1 if @min >= MINUTESINHOUR
  391.       @hour = h if !h.nil?
  392.       @hour = HOURSINDAY - 1 if @hour >= HOURSINDAY
  393.       @day = d if !d.nil?
  394.       @day = MONTHS[@month] - 1 if @day >= MONTHS[@month]
  395.       @dayweek = dw if !dw.nil?
  396.       @dayweek = 0 if @dayweek >= DAYNAMES.size
  397.       @month = mn if !mn.nil?
  398.       @month = MONTHS.size - 1 if @month >= MONTHS.size
  399.       @year = y if !y.nil?
  400.     end
  401.     def forward(handle,n)
  402.       handle = handle.to_s + "(1)"
  403.       n.times do |s| eval(handle) end
  404.     end
  405.     def remsec(s)
  406.       @sec -= s
  407.       return unless @sec == -1
  408.       @sec = SECONDSINMIN
  409.       remmin(1)
  410.     end
  411.     def remmin(m)
  412.       @min -= m
  413.       return unless @min == -1
  414.       @min = MINUTESINHOUR
  415.       remhour(1)
  416.     end
  417.     def remhour(h)
  418.       @hour -= h
  419.       return unless @hour == -1
  420.       @hour = HOURSINDAY - 1
  421.       remday(1)
  422.     end
  423.     def remday(d)
  424.       @day -= d
  425.       @dayweek -= d
  426.       @dayweek = DAYNAMES.size - 1 if @dayweek == -1
  427.       return unless @day == -1
  428.       @day = MONTHS[@month] - 1
  429.       remmonth(1)
  430.     end
  431.     def remmonth(mn)
  432.       @month -= mn
  433.       return unless @month == -1
  434.       @month = MONTHS.size - 1
  435.       remyear(1)
  436.     end
  437.     def remyear(y)
  438.       @year -= y
  439.     end
  440.   end</P>
  441. <P>  class Sprite_TimeTint < Sprite_Base
  442.     def initialize(viewport = nil)
  443.       super(viewport)
  444.       self.z = 1
  445.       create_contents
  446.       update
  447.       @old_tint = [0,0,0,0]
  448.       @old_time = 0
  449.     end
  450.     def create_contents
  451.       self.bitmap = Bitmap.new(Graphics.width,Graphics.height)
  452.       self.visible = false
  453.     end
  454.     def update
  455.       return use_default if SceneManager.scene.is_a?(Scene_Battle) and BATTLE_TINT
  456.       return use_khas if USE_KHAS
  457.       return use_victor if USE_VICTOR
  458.       return use_default
  459.     end
  460.     def use_default
  461.       return if self.disposed?
  462.       create_contents if self.bitmap.height != Graphics.height
  463.       create_contents if self.bitmap.width != Graphics.width
  464.       self.visible = SceneManager.scene.is_a?(Scene_Map)
  465.       self.visible = true if SceneManager.scene.is_a?(Scene_Battle) and BATTLE_TINT
  466.       self.visible = false if SceneManager.scene.is_a?(Scene_Title)
  467.       self.visible = false if no_tint
  468.       self.bitmap.clear if no_tint
  469.       return unless self.visible
  470.       min = $game_time.min
  471.       return if min == @old_time
  472.       @old_time = min
  473.       rgba = get_new_tint(min)
  474.       return if rgba == @old_tint
  475.       @old_tint = rgba
  476.       self.bitmap.clear
  477.       self.bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(rgba[0],rgba[1],rgba[2],rgba[3]))
  478.     end
  479.     def use_khas      
  480.       begin
  481.       temp = $game_map.light_surface.opacity
  482.       rescue
  483.       return
  484.       end
  485.       self.visible = false
  486.       $game_map.effect_surface.change_color(1,0,0,0,0) if no_tint
  487.       return if no_tint
  488.       min = $game_time.min
  489.       return if min == @old_time
  490.       @old_time = min
  491.       rgba = get_new_tint(min)
  492.       return if rgba == @old_tint
  493.       @old_tint = rgba
  494.       $game_map.effect_surface.change_color(1,rgba[0],rgba[1],rgba[2],rgba[3])
  495.     end
  496.     def no_tint
  497.       return if $game_map.nil?
  498.       note = $game_map.map_note
  499.       /Notint/ =~ note
  500.       return false unless $~
  501.       return true
  502.     end
  503.     def use_victor
  504.       return if $game_map.nil?
  505.       self.visible = false
  506.       $game_map.screen.shade.change_color(0,0,0,0) if no_tint
  507.       $game_map.screen.shade.change_opacity(0) if no_tint
  508.       return if no_tint
  509.       $game_map.screen.shade.show if !$game_map.screen.shade.visible
  510.       min = $game_time.min
  511.       return if min == @old_time
  512.       @old_time = min
  513.       rgba = get_new_tint(min)
  514.       return if rgba == @old_tint
  515.       @old_tint = rgba
  516.       $game_map.screen.shade.change_color(rgba[0],rgba[1],rgba[2],0)
  517.       $game_map.screen.shade.change_opacity(rgba[3],0)
  518.     end
  519.     def get_new_tint(min)
  520.       ctint = TINTS[$game_time.hour]
  521.       ntint = TINTS[$game_time.hour + 1] unless $game_time.hour + 1 == HOURSINDAY
  522.       ntint = TINTS[0] if $game_time.hour + 1 == HOURSINDAY
  523.       r = ctint.red.to_f - ((ctint.red.to_f - ntint.red) * (min.to_f / MINUTESINHOUR))
  524.       g = ctint.green.to_f - ((ctint.green.to_f - ntint.green) * (min.to_f / MINUTESINHOUR))
  525.       b = ctint.blue.to_f - ((ctint.blue.to_f - ntint.blue) * (min.to_f / MINUTESINHOUR))
  526.       a = ctint.alpha.to_f - ((ctint.alpha.to_f - ntint.alpha) * (min.to_f / MINUTESINHOUR))
  527.       return [r,g,b,a]
  528.     end
  529.   end</P>
  530. <P>  class Window_GameClock < Window_Base
  531.     def initialize
  532.       super(CLOCK_X,CLOCK_Y,CLOCK_WIDTH,clock_height)
  533.       self.opacity = CLOCK_BACK unless SceneManager.scene.is_a?(Scene_Menu)
  534.       update
  535.       self.visible = $gametimeclockvisible unless SceneManager.scene.is_a?(Scene_Menu)
  536.     end
  537.     def clock_height
  538.       return 80 if !CUSTOM_CLOCK2.nil? and CLOCK_FORMAT == 5 and SceneManager.scene.is_a?(Scene_Map)
  539.       return 80 if !CUSTOM_CLOCK2.nil? and MENU_CLOCK_FORMAT == 5 and SceneManager.scene.is_a?(Scene_Menu)
  540.       return 56
  541.     end
  542.     def update
  543.       if NOSECONDS && @set_minute == $game_time.min
  544.         if Graphics.frame_count % BLINK_SPEED / 2 == 0 && USE_BLINK
  545.           return
  546.         end
  547.       end
  548.       contents.clear
  549.       @set_minute = $game_time.min if NOSECONDS
  550.       if SceneManager.scene.is_a?(Scene_Map)
  551.         v = CLOCK_FORMAT
  552.       else
  553.         v = MENU_CLOCK_FORMAT
  554.       end
  555.       string = normal_clock if v == 1
  556.       string = dated_clock if v == 2
  557.       string = military_clock if v == 3
  558.       string = dated_military_clock if v == 4
  559.       string = custom(CUSTOM_CLOCK) if v == 5
  560.       string2 = custom(CUSTOM_CLOCK2) if !CUSTOM_CLOCK2.nil? and v == 5
  561.       contents.draw_text(0,0,contents.width,24,string,1)
  562.       contents.draw_text(0,24,contents.width,24,string2,1) if !CUSTOM_CLOCK2.nil? and v == 5
  563.     end
  564.     def military_clock
  565.       hour = $game_time.hour
  566.       minute = $game_time.min
  567.       if hour < 10 then hour = " " + hour.to_s else hour.to_s end
  568.       if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
  569.       string =  hour.to_s + blinky + minute.to_s
  570.       return string
  571.     end
  572.     def dated_military_clock
  573.       hour = $game_time.hour
  574.       minute = $game_time.min
  575.       dayweek = DAYNAMESABBR[$game_time.dayweek]
  576.       day = $game_time.day
  577.       day += 1 unless USE_REAL_TIME
  578.       if hour < 10 then hour = " " + hour.to_s else hour.to_s end
  579.       if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
  580.       if day < 10 then day = " " + day.to_s end
  581.       string = dayweek.to_s + " " + day.to_s + " "
  582.       string += hour.to_s + blinky + minute.to_s
  583.       return string
  584.     end
  585.     def normal_clock
  586.       meri = "AM"
  587.       hour = $game_time.hour
  588.       minute = $game_time.min
  589.       if hour > 11 then meri = "PM" end
  590.       if hour == 0 then hour = 12; meri = "AM" end
  591.       if hour > 12 then hour -= 12 end
  592.       if hour < 10 then hour = " " + hour.to_s else hour.to_s end
  593.       if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
  594.       string =  hour.to_s + blinky + minute.to_s + " " + meri
  595.       return string
  596.     end
  597.     def dated_clock
  598.       meri = "AM"
  599.       hour = $game_time.hour
  600.       minute = $game_time.min
  601.       dayweek = DAYNAMESABBR[$game_time.dayweek]
  602.       day = $game_time.day
  603.       day += 1 unless USE_REAL_TIME
  604.       if hour > 11 then meri = "PM" end
  605.       if hour == 0 then hour = 12; meri = "AM" end
  606.       if hour > 12 then hour -= 12 end
  607.       if hour < 10 then hour = " " + hour.to_s else hour.to_s end
  608.       if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
  609.       if day < 10 then day = " " + day.to_s end
  610.       string = dayweek.to_s + " " + day.to_s + " "
  611.       string += hour.to_s + blinky + minute.to_s + " " + meri
  612.       return string
  613.     end
  614.     def blinky
  615.       return ":" unless USE_BLINK
  616.       return " " if Graphics.frame_count % BLINK_SPEED > (BLINK_SPEED / 2)
  617.       return ":"
  618.     end
  619.     def custom(array)
  620.       string = ""
  621.       for command in array
  622.         case command
  623.         when "sec"
  624.           sec = $game_time.sec
  625.           sec = "0" + sec.to_s if sec < 10
  626.           string += sec.to_s
  627.         when "min"
  628.           minute = $game_time.min
  629.           minute = "0" + minute.to_s if minute < 10
  630.           string += minute.to_s
  631.         when "hour"
  632.           hour = $game_time.hour
  633.           hour >= 12 ? meri = "PM" : meri = "AM"
  634.           hour = " " + hour.to_s if hour < 10
  635.           string += hour.to_s
  636.         when "hour12"
  637.           hour12 = $game_time.hour
  638.           hour12 -= 12 if hour12 > 12
  639.           hour12 = 12 if hour12 == 0
  640.           string += hour12.to_s
  641.         when "meri"
  642.           string += meri.to_s
  643.         when "weekshort"
  644.           dayweek = DAYNAMESABBR[$game_time.dayweek]
  645.           string += dayweek.to_s
  646.         when "weeklong"
  647.           dayweekn = DAYNAMES[$game_time.dayweek]
  648.           string += dayweekn.to_s
  649.         when "day"
  650.           day = $game_time.day
  651.           day += 1 unless USE_REAL_TIME
  652.           string += day.to_s
  653.         when "month"
  654.           month = $game_time.month
  655.           month += 1 unless USE_REAL_TIME
  656.           string += month.to_s
  657.         when "monthshort"
  658.           monthna = MONTHNAMESABBR[$game_time.month]
  659.           string += monthna.to_s
  660.         when "monthlong"
  661.           monthn = MONTHNAMES[$game_time.month]
  662.           string += monthn.to_s
  663.         when "year"
  664.           year = $game_time.year
  665.           string += year.to_s
  666.         when "yearp"
  667.           string += $game_time.year_post
  668.         when "blinky"
  669.           string += blinky
  670.         else
  671.           string += command.to_s
  672.         end
  673.       end
  674.       return string
  675.     end
  676.   end</P>
  677. <P>end</P>
  678. <P>GameTime.run</P>
  679. <P>class Window_Base < Window
  680.   alias real_time_convert_escape_characters convert_escape_characters
  681.   def convert_escape_characters(text)
  682.     result = real_time_convert_escape_characters(text)
  683.     result.gsub!(/GTSEC/) { GameTime.sec? }
  684.     result.gsub!(/GTMIN/) { GameTime.min? }
  685.     result.gsub!(/GTHOUR/) { GameTime.hour? }
  686.     result.gsub!(/GTDAYN/) { GameTime.day? }
  687.     result.gsub!(/GTDAYF/) { GameTime.day_name }
  688.     result.gsub!(/GTDAYA/) { GameTime.day_name_abbr }
  689.     result.gsub!(/GTMONF/) { GameTime.month? }
  690.     result.gsub!(/GTMONN/) { GameTime.month_name }
  691.     result.gsub!(/GTMONA/) { GameTime.month_name_abbr }
  692.     result.gsub!(/GTYEAR/) { GameTime.year? }
  693.     result
  694.   end
  695. end</P>
  696. <P>class Scene_Base
  697.   alias game_time_update update
  698.   def update
  699.     game_time_update
  700.     GameTime.update
  701.   end
  702. end</P>
  703. <P>class Scene_Map
  704.   alias game_time_post_transfer post_transfer
  705.   alias game_time_init create_all_windows
  706.   alias game_time_map_update update
  707.   alias game_time_start start
  708.   def start
  709.     game_time_start
  710.     GameTime.update_tint
  711.   end
  712.   def create_all_windows
  713.     game_time_init
  714.     @gametimeclock = GameTime::Window_GameClock.new if USECLOCK
  715.   end
  716.   def post_transfer
  717.     GameTime.update_tint
  718.     game_time_post_transfer
  719.   end
  720.   def update
  721.     game_time_map_update
  722.     return unless USECLOCK
  723.     @gametimeclock.update unless SceneManager.scene != self
  724.     if Input.trigger?(CLOCK_TOGGLE) and @gametimeclock.nil? == false
  725.       @gametimeclock.visible ? @gametimeclock.visible = false : @gametimeclock.visible = true
  726.       $gametimeclockvisible = @gametimeclock.visible
  727.     end
  728.   end
  729.   def clock_visible?(set)
  730.     @gametimeclock.visible = set
  731.   end
  732.   def update_encounter
  733.     if $game_player.encounter
  734.       $game_time_tint.use_default
  735.       SceneManager.call(Scene_Battle)
  736.     end
  737.   end
  738. end</P>
  739. <P>class Game_Map
  740.   def map_note
  741.     return @map.note unless @map.nil?
  742.   end
  743. end</P>
  744. <P>class Scene_Menu
  745.   alias gt_start start
  746.   alias gt_update update
  747.   def start
  748.     gt_start
  749.     [url=home.php?mod=space&uid=434406]@clock[/url] = GameTime::Window_GameClock.new if USECLOCK_MENU
  750.     return if @clock.nil?
  751.     @clock.x = 0
  752.     @clock.y = @gold_window.y - @clock.height
  753.     @clock.width = @gold_window.width
  754.     @clock.create_contents
  755.   end
  756.   def update
  757.     gt_update
  758.     @clock.update unless @clock.nil?
  759.     @clock.contents.clear if SceneManager.scene != self and <A href="mailto:[email protected]">!@clock.nil</A>?
  760.   end
  761. end</P>
  762. <P>class Scene_Battle
  763.   def pre_terminate
  764.     super
  765.     Graphics.fadeout(30) if SceneManager.scene_is?(Scene_Map)
  766.     Graphics.fadeout(60) if SceneManager.scene_is?(Scene_Title)
  767.     $game_time_tint.update
  768.   end
  769. end</P>
  770. <P>module DataManager
  771.   class << self
  772.   alias gametime_msc make_save_contents
  773.   alias gametime_esc extract_save_contents
  774.   alias gametime_sng setup_new_game
  775.   end
  776.   def self.make_save_contents
  777.     contents = gametime_msc
  778.     contents[:gametime] = $game_time
  779.     contents
  780.   end
  781.   def self.extract_save_contents(contents)
  782.     gametime_esc(contents)
  783.     $game_time = contents[:gametime]
  784.   end
  785.   def self.setup_new_game
  786.     gametime_sng
  787.     $game_time = GameTime::Current_Time.new
  788.   end
  789. end</P>
很多年了呢,坑还是没填完…………(草

Lv1.梦旅人

梦石
0
星屑
155
在线时间
129 小时
注册时间
2014-2-22
帖子
233
9
 楼主| 发表于 2014-3-17 12:30:21 | 只看该作者
Sion 发表于 2014-3-16 22:56
我不知道为啥它这个 @hour 是 0 但它要显示 12
你每次设定都应该要精确到分钟,然后加一个这个:避免在这一 ...

嗯,因为这系统默认是12时制,所以就这样了…………108和109行能改的
另外在加上&& Graphics.frame_count%60==30 就不行了,去掉就会执行两次事件…………不晓得是什么毛病
掉帧貌似没发现,稳定在58上下
算了回头自己研究下是什么问题

点评

你可以直接找到 @min 修改的地方,在这里加判断。这样就没有 update 里的这些问题了。掉帧的话,可能我的 CPU 不行吧。  发表于 2014-3-17 13:47
很多年了呢,坑还是没填完…………(草
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

8
发表于 2014-3-16 22:56:35 | 只看该作者
本帖最后由 Sion 于 2014-3-16 23:03 编辑

我不知道为啥它这个 @hour 是 0 但它要显示 12
你每次设定都应该要精确到分钟,然后加一个这个:
  1. if @hour == 0 && @min== 3 && Graphics.frame_count%60==30 #12:03 执行一次
  2. #...
  3. end
复制代码
避免在这一秒内每一帧都会预定一次公共事件。
顺便吐槽下,这个脚本掉帧也太多了。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
155
在线时间
129 小时
注册时间
2014-2-22
帖子
233
7
 楼主| 发表于 2014-3-16 22:29:08 | 只看该作者
Sion 发表于 2014-3-16 19:58
在 update 里添加判断
下面那个 @sec @min 什么的就是秒、分、时了。
满足条件的话就用 $game_temp.reserv ...

是这样插入么?为什么没有反应(第322到349行)
  1.     def reset_all_values
  2.       @sec = START_TIME[0]
  3.       [url=home.php?mod=space&uid=25749]@min[/url] = START_TIME[1]
  4.       @hour = START_TIME[2]
  5.       [url=home.php?mod=space&uid=11519]@day[/url] = START_TIME[3]
  6.       @dayweek = 0
  7.       [url=home.php?mod=space&uid=26122]@Month[/url] = START_TIME[4]
  8.       @year = START_TIME[5]
  9.       @notime = false
  10.       @year_post = DEFAULT_YEAR_POST
  11.     end
  12.     def update
  13.       if @hour == 12 && @min== 20#12:20 启动公共事件1
  14.       $game_temp.reserve_common_event(9)
  15.       end
  16.       return realtime if USE_REAL_TIME
  17.       return if GameTime.no_time_map or @notime
  18.       $game_variables[TIMELAPSE_VARIABLE] = DEFAULT_TIMELAPSE if $game_variables[TIMELAPSE_VARIABLE] <= 0
  19.       return unless Graphics.frame_count % $game_variables[TIMELAPSE_VARIABLE] == 0
  20.       NOSECONDS ? addmin(1) : addsec(1)
  21.       update_timers
  22.     end
  23.     def update_timers
  24.       return unless TIMER_VARIABLES.size > 0
  25.       for i in TIMER_VARIABLES
  26.         $game_variables[i] -= 1 unless $game_variables[i] == 0
  27.       end
  28.     end
复制代码
很多年了呢,坑还是没填完…………(草
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

6
发表于 2014-3-16 19:58:42 | 只看该作者
本帖最后由 Sion 于 2014-3-16 20:01 编辑


在 update 里添加判断
下面那个 @sec @min 什么的就是秒、分、时了。
满足条件的话就用 $game_temp.reserve_common_event(x) 来启动对应的公共事件
比如
  1. def update
  2.   if @hour == 12 && @min== 20#12:20 启动公共事件1
  3.       $game_temp.reserve_common_event(1)
  4.   end
  5.   #.......
  6. end
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
155
在线时间
129 小时
注册时间
2014-2-22
帖子
233
5
 楼主| 发表于 2014-3-16 19:32:44 | 只看该作者
Sion 发表于 2014-3-16 19:22
这脚本里的 和 是怎么回事,你给个直接能用的工程吧。

几乎是即插即用的,我也不知道为什么会有<p>

Project2.rar

305.85 KB, 下载次数: 30

很多年了呢,坑还是没填完…………(草
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

4
发表于 2014-3-16 19:22:01 | 只看该作者
这脚本里的<P> 和</P> 是怎么回事,你给个直接能用的工程吧。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
155
在线时间
129 小时
注册时间
2014-2-22
帖子
233
3
 楼主| 发表于 2014-3-16 09:16:54 | 只看该作者
david_ng223 发表于 2014-3-15 19:45
$game_time.sec
$game_time.min
$game_time.hour

忘记说清楚了,严重失误,再次道歉。想达成的目标是:
每到一定时候执行一个指定的公共事件,例如每天的XX点或是每年的XX月XX日(类似于生日事件)
这脚本倒是不错,我还不想把他弃坑了
@Sion 大神求帮忙
很多年了呢,坑还是没填完…………(草
回复 支持 反对

使用道具 举报

david_ng223 该用户已被删除
2
发表于 2014-3-15 19:45:13 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-25 07:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表