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

Project1

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

[RMVX发布] 日期时间显示脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
32 小时
注册时间
2011-7-15
帖子
38
跳转到指定楼层
1
发表于 2012-3-20 16:46:23 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 414447674 于 2012-3-25 14:14 编辑

小弟献丑了啊(第一次写脚本啊), 有什么不明白的问我, 如有BUG请告诉我{:1_1:}@
这段脚本参考了地图名显示脚本:http://rpg.blue/thread-73692-1-1.html
建议配合随着时间而改变地图颜色的脚本使用, 这里有一个:http://rpg.blue/thread-107005-1-1.html
  1. #==============================================================================
  2. # ■ 日期時間顯示腳本
  3. #     by 414447674
  4. #------------------------------------------------------------------------------
  5. # 在Main的上方插入一個頁,將本腳本複製到那頁中即可
  6. #==============================================================================

  7. #==============================================================================
  8. # ■ Window_Time
  9. #------------------------------------------------------------------------------
  10. #  顯示日期時間的視窗。
  11. #==============================================================================

  12. class Window_Time < Window_Base
  13.   #--------------------------------------------------------------------------
  14.   # ● 類常量定義
  15.   #--------------------------------------------------------------------------

  16.   # 日期、時間的變數
  17.   $v_year = 1        #年份
  18.   $v_month = 2       #月份
  19.   $v_day = 3         #日期
  20.   $v_hour = 4        #小時
  21.   $v_min = 5         #分鐘
  22.   $v_sec = 6         #秒鐘
  23.   $v_battle_sec = 7  #戰鬥時遺留的時間
  24.   $v_week = 8        #今天的星期數
  25.   
  26.   # 正常時是否顯示時間的開關
  27.   $normal_switch = 1
  28.   
  29.   # 戰鬥時是否顯示時間的開關
  30.   $battle_switch = 2
  31.   
  32.   # 開始時間流動的開關
  33.   $start_time = 3
  34.   
  35.   # 戰鬥時時間是否流動的開關
  36.   $battle_time = 4
  37.   
  38.   # 戰鬥時時間流動是正常的多少分之一
  39.   $battle_flow_time = 60
  40.   
  41.   # 現實中一秒等於游戲裏的多少分鐘
  42.   $min = 1

  43.   # 常規設定
  44.   $month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  45.   $week_day_name = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  46.   $start_date = [2012, 1, 1, 0, 0, 0, 0]
  47.   # 起始時間 [年份, 月份, 日期, 小時, 分鐘, 秒鐘, 第一天星期幾]
  48.   
  49.   # 窗口位置設定
  50.   NAME_X = 0        # 矩形左上頂點X座標
  51.   NAME_Y = 0        # 矩形左上頂點Y座標
  52.   NAME_W = 280      # 矩形寬
  53.   NAME_H = 60       # 矩形高
  54.   
  55.   # 完全可見時的透明度設置
  56.   OPACITY_1 = 244   # 邊框
  57.   OPACITY_2 = 100   # 背景
  58.   OPACITY_3 = 255   # 文字
  59.   
  60.   # 日曆的顏色
  61.   TEXT_COLOR = Color.new(255, 255, 255, 255)
  62.    
  63.   #--------------------------------------------------------------------------
  64.   # ● 初始化狀態
  65.   #--------------------------------------------------------------------------
  66.   def initialize
  67.     super(NAME_X , NAME_Y, NAME_W, NAME_H)
  68.     # 初始化窗口透明度
  69.     self.opacity = 0
  70.     self.back_opacity = 0
  71.     self.z = 9999
  72.     self.contents_opacity = 0
  73.     self.contents = Bitmap.new(width - 32, height - 32)
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 輸出時間
  77.   #--------------------------------------------------------------------------
  78.   def settime(in_battle = false, see = true)
  79.     self.contents.clear
  80.     self.contents.font.color = TEXT_COLOR
  81.     text = sprintf("%4d/%2d/%2d (", $game_variables[$v_year], $game_variables[$v_month], $game_variables[$v_day])
  82.     text += $week_day_name[$game_variables[$v_week]]
  83.     text += sprintf(")  %02d:%02d", $game_variables[$v_hour], $game_variables[$v_min])
  84.     if in_battle
  85.       text += sprintf(":%02d", $game_variables[$v_sec])
  86.     end
  87.     # 描繪時間
  88.     self.contents.draw_text(4, 0 , width - 40, 32, text, 1)
  89.     # 窗口透明度
  90.     if see
  91.       self.opacity = OPACITY_1
  92.       self.back_opacity = OPACITY_2
  93.       self.contents_opacity = OPACITY_3
  94.     else
  95.       self.opacity = 0
  96.       self.back_opacity = 0
  97.       self.contents_opacity = 0
  98.     end
  99.   end
  100. end

  101. #==============================================================================
  102. # ■ Scene_Map
  103. #------------------------------------------------------------------------------
  104. #  處理地圖畫面的類。(追加定義)
  105. #==============================================================================

  106. class Scene_Map
  107.   
  108.   def date_refresh
  109.     if $game_variables[$v_day] > $month[$game_variables[$v_month]] and $game_variables[$v_month] != 2
  110.       $game_variables[$v_day] -= $month[$game_variables[$v_month]]
  111.       $game_variables[$v_month] += 1
  112.     elsif (($game_variables[$v_year] % 4 == 0 and $game_variables[$v_year] % 100 != 0) or $game_variables[$v_year] % 400 == 0) and $game_variables[$v_month] == 2 and $game_variables[$v_day] > 29
  113.       $game_variables[$v_day] -= 29
  114.       $game_variables[$v_month] = 3
  115.     elsif ($game_variables[$v_year] % 4 != 0 or ($game_variables[$v_year] % 100 == 0 and $game_variables[$v_year] % 400 != 0)) and $game_variables[$v_month] == 2 and $game_variables[$v_day] > 28
  116.       $game_variables[$v_day] -= 28
  117.       $game_variables[$v_month] = 3
  118.     end
  119.     if $game_variables[$v_month] > 12
  120.       $game_variables[$v_month] -= 12
  121.       $game_variables[$v_year] += 1
  122.     end
  123.     if $game_variables[$v_day] < 0 and $game_variables[$v_month - 1] != 2
  124.       $game_variables[$v_day] += $month[$game_variables[$v_month - 1]]
  125.       $game_variables[$v_month] -= 1
  126.     elsif (($game_variables[$v_year] % 4 == 0 and $game_variables[$v_year] % 100 != 0) or $game_variables[$v_year] % 400 == 0) and $game_variables[$v_month - 1] == 2 and $game_variables[$v_day] < 0
  127.       $game_variables[$v_day] += 29
  128.       $game_variables[$v_month] = 2
  129.     elsif ($game_variables[$v_year] % 4 != 0 or ($game_variables[$v_year] % 100 == 0 and $game_variables[$v_year] % 400 != 0)) and $game_variables[$v_month - 1] == 2 and $game_variables[$v_day] < 0
  130.       $game_variables[$v_day] += 28
  131.       $game_variables[$v_month] = 2
  132.     end
  133.     if $game_variables[$v_month] < 0
  134.       $game_variables[$v_month] += 12
  135.       $game_variables[$v_year] -= 1
  136.     end
  137.   end
  138.   
  139.   def time_refresh
  140.     while $game_variables[$v_sec] >= 60
  141.       $game_variables[$v_sec] -= 60
  142.       $game_variables[$v_min] += 1
  143.     end
  144.     while $game_variables[$v_min] >= 60
  145.       $game_variables[$v_min] -= 60
  146.       $game_variables[$v_hour] += 1
  147.     end
  148.     while $game_variables[$v_hour] >= 24
  149.       $game_variables[$v_hour] -= 24
  150.       $game_variables[$v_day] += 1
  151.       $game_variables[$v_week] += 1
  152.       $game_variables[$v_week] %= 7
  153.       date_refresh
  154.     end
  155.     while $game_variables[$v_sec] < 0
  156.       $game_variables[$v_sec] += 60
  157.       $game_variables[$v_min] -= 1
  158.     end
  159.     while $game_variables[$v_min] < 0
  160.       $game_variables[$v_min] += 60
  161.       $game_variables[$v_hour] -= 1
  162.     end
  163.     while $game_variables[$v_hour] < 0
  164.       $game_variables[$v_hour] += 24
  165.       $game_variables[$v_day] -= 1
  166.       $game_variables[$v_week] -= 1
  167.       $game_variables[$v_week] += 7 if $game_variables[$v_week] < 0
  168.       date_refresh
  169.     end
  170.   end
  171.   
  172.   alias day_start start
  173.   def start
  174.     @time = Window_Time.new
  175.     day_start
  176.   end
  177.   
  178.   alias day_dispose terminate
  179.   def terminate
  180.     day_dispose
  181.     @time.dispose
  182.   end
  183.   
  184.   alias day_update update
  185.   def update
  186.      day_update
  187.     if $game_switches[$start_time]
  188.       $game_variables[$v_sec] += $min
  189.       if $game_variables[$v_sec] >= 60
  190.         time_refresh
  191.       end
  192.     end
  193.     if $game_switches[$normal_switch]
  194.       @time.settime
  195.     else
  196.       @time.settime(false, false)
  197.     end
  198.   end
  199. end

  200. #==============================================================================
  201. # ** Scene_Title
  202. #------------------------------------------------------------------------------
  203. #  這個類用來執行顯示標題畫面的程式。(追加定義)
  204. #==============================================================================

  205. class Scene_Title < Scene_Base
  206.   
  207.   alias new_game command_new_game
  208.   def command_new_game
  209.     new_game
  210.     $game_variables[$v_year] = $start_date[0]
  211.     $game_variables[$v_month] = $start_date[1]
  212.     $game_variables[$v_day] = $start_date[2]
  213.     $game_variables[$v_hour] = $start_date[3]
  214.     $game_variables[$v_min] = $start_date[4]
  215.     $game_variables[$v_sec] = $start_date[5]
  216.     $game_variables[$v_week] = $start_date[6]
  217.   end
  218. end

  219. #==============================================================================
  220. # ** Scene_Battle
  221. #------------------------------------------------------------------------------
  222. #  這個類用來執行顯示作戰畫面的程式。(追加定義)
  223. #==============================================================================

  224. class Scene_Battle < Scene_Base
  225.   
  226.   alias day_start start
  227.   def start
  228.     @time = Window_Time.new
  229.     day_start
  230.   end
  231.   
  232.   alias day_update update_basic
  233.   def update_basic(main = false)
  234.     day_update(main)
  235.     if $game_switches[$battle_time]
  236.       $game_variables[$v_battle_sec] += $min
  237.       if $game_variables[$v_battle_sec] >= $battle_flow_time
  238.         @time2 = Scene_Map.new
  239.         $game_variables[$v_battle_sec] -= $battle_flow_time
  240.         $game_variables[$v_sec] += 1
  241.         if $game_variables[$v_sec] >= 60
  242.           @time2.time_refresh
  243.         end
  244.       end
  245.     end
  246.     if $game_switches[$battle_switch]
  247.       @time.settime(true)
  248.     else
  249.       @time.settime(true, false)
  250.     end
  251.   end

  252.   alias day_terminate terminate
  253.   def terminate
  254.     @time.dispose
  255.     day_terminate
  256.   end
  257. end
  258. #==============================================================================
  259. # ** Scene_File
  260. #------------------------------------------------------------------------------
  261. #  這個類用來執行顯示存取進度畫面的程式。(追加定義)
  262. #==============================================================================

  263. class Scene_File < Scene_Base
  264.   def write_save_data(file)
  265.     characters = []
  266.     for actor in $game_party.members
  267.       characters.push([actor.character_name, actor.character_index])
  268.     end
  269.     $game_system.save_count += 1
  270.     $game_system.version_id = $data_system.version_id
  271.     @last_bgm = RPG::BGM::last
  272.     @last_bgs = RPG::BGS::last
  273.     Marshal.dump(characters,           file)
  274.     Marshal.dump(Graphics.frame_count, file)
  275.     Marshal.dump(@last_bgm,            file)
  276.     Marshal.dump(@last_bgs,            file)
  277.     Marshal.dump($game_system,         file)
  278.     Marshal.dump($game_message,        file)
  279.     Marshal.dump($game_switches,       file)
  280.     Marshal.dump($game_variables,      file)
  281.     Marshal.dump($game_self_switches,  file)
  282.     Marshal.dump($game_actors,         file)
  283.     Marshal.dump($game_party,          file)
  284.     Marshal.dump($game_troop,          file)
  285.     Marshal.dump($game_map,            file)
  286.     Marshal.dump($game_player,         file)
  287.     Marshal.dump($min,                 file)
  288.   end
  289.   def read_save_data(file)
  290.     characters           = Marshal.load(file)
  291.     Graphics.frame_count = Marshal.load(file)
  292.     @last_bgm            = Marshal.load(file)
  293.     @last_bgs            = Marshal.load(file)
  294.     $game_system         = Marshal.load(file)
  295.     $game_message        = Marshal.load(file)
  296.     $game_switches       = Marshal.load(file)
  297.     $game_variables      = Marshal.load(file)
  298.     $game_self_switches  = Marshal.load(file)
  299.     $game_actors         = Marshal.load(file)
  300.     $game_party          = Marshal.load(file)
  301.     $game_troop          = Marshal.load(file)
  302.     $game_map            = Marshal.load(file)
  303.     $game_player         = Marshal.load(file)
  304.     $min                 = Marshal.load(file)
  305.     if $game_system.version_id != $data_system.version_id
  306.       $game_map.setup($game_map.map_id)
  307.       $game_player.center($game_player.x, $game_player.y)
  308.     end
  309.   end
  310. end
  311. #==============================================================================
  312. # ** Game_Interpreter
  313. #------------------------------------------------------------------------------
  314. #  這個類是用來執行事件指令的直譯器。
  315. #  這個類作為 Game_Map、Game_Troop 和 Game_Event 的內部類使用。(追加定義)
  316. #==============================================================================

  317. class Game_Interpreter
  318.   def change_time(year, month, day, hour, min, sec)
  319.     $game_variables[$v_year] += year
  320.     $game_variables[$v_month] += month
  321.     $game_variables[$v_day] += day
  322.     $game_variables[$v_hour] += hour
  323.     $game_variables[$v_min] += min
  324.     $game_variables[$v_sec] += sec
  325.     @time = Scene_Map.new
  326.     @time.time_refresh
  327.   end
  328. end
复制代码
如果想改变时间流动的速度可以直接在事件裏输入RGSS脚本: $min = X, X是现实一秒, 游戏过多少分钟(储存时会储存)
如果想改时间也是在事件裏输入RGSS脚本 change_time(A, B, C, D, E, F), 这是时间增加多少(减少的话就输入负数), A是年, B是月, C是日, D是小时, E是分钟, F是秒钟

请各位大哥给些意见

评分

参与人数 1星屑 +332 收起 理由
冰舞蝶恋 + 332 加油!~

查看全部评分

E

Lv2.观梦者

花开堪折直须折

梦石
0
星屑
636
在线时间
943 小时
注册时间
2010-7-17
帖子
4963

贵宾

2
发表于 2012-3-20 18:47:18 | 只看该作者
加油。脚本其实可以简短一点的唔……好吧半年没动我学的那点vx脚本常识全部还给老师。。呃,6R了。。


‘‘──冰舞蝶恋于2012-3-20 18:48补充以下内容

比方说变量那些一长串的可以用数组啊……
’’
大家好,我叫节操,有一天,我被吃了。
http://forever-dream.5d6d.com
永恒の梦制作组论坛

129993099
永恒の梦制作组QQ群
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
32 小时
注册时间
2011-7-15
帖子
38
3
 楼主| 发表于 2012-3-20 19:00:43 | 只看该作者
本帖最后由 414447674 于 2012-3-20 19:02 编辑

是应该改一下,谢谢
不过, 有空再说...
E
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
39
在线时间
115 小时
注册时间
2012-1-23
帖子
103
4
发表于 2012-8-6 08:56:49 | 只看该作者
纯事件就能做出来……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
977 小时
注册时间
2011-5-13
帖子
292
5
发表于 2012-8-6 09:20:45 | 只看该作者
我很喜欢这类脚本,有没XP参考版的,VX实在看不下?
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-6-11 00:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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