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

Project1

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

[已经解决] 时间显示脚本求助

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1428
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
跳转到指定楼层
1
发表于 2014-9-22 11:51:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
这个是图书馆里找到的显示时间的脚本,我想要通过开关控制显示和不显示(注意是显示和不显示而不是计不计时!)也就是脚本上面Map = :none这个地方,目前只能初始设置好显示不显示而无法在游戏中更改
  1. #==============================================================================
  2. # ** 虚拟日历
  3. #  作者:影月千秋
  4. #  适用:VA
  5. #  要求:Smomo脚本核心 1.0+
  6. #------------------------------------------------------------------------------
  7. # * 简介:
  8. #  模拟时间流逝,并在地图(菜单)进行显示
  9. #  可以自定义计时规则和显示效果
  10. #  请为本脚本准备变量和开关,在下方进行设定
  11. #  本脚本需要Smomo脚本核心,请到此下载:http://tinyurl.com/l9kvg2p
  12. #  如果链接失效,请到rpg.blue,[url=home.php?mod=space&uid=426609]@余烬之中[/url] 或 @影月千秋
  13. #------------------------------------------------------------------------------
  14. # * 使用方法:
  15. #  将此脚本插入到其他脚本以下,Main以上,在下面给出的设定区进行设定后即可
  16. #  在事件中操作指定的变量和开关,便可以获取和改变时间
  17. #  也可以通过事件脚本进行操作
  18. #  允许的脚本呼叫:
  19. #    Smomo.calendar(type) 取得日历的内部数据
  20. #   参数说明:type 想要获得的数据名
  21. #       【:all】 获取所有数据的数组 依次为:时段 色调 刷新标志 周期历时 周期序号
  22. #       【:zone】获取当前时段的名称(如:"早晨")
  23. #       【:tone】不常用,获取当前色调(Tone色调类的实例)
  24. #       【:need_change】没有任何实用意义,不常用,可以获取需要刷新的标志
  25. #       【:period】当前周期经过的时间(如:1366)
  26. #       【:prd】当前周期的序号,对应在周期名字(如:3)
  27. #   例:【Smomo.calendar(:zone)】获取时段名
  28. #------------------------------------------------------------------------------
  29. # * 版本:
  30. #   V 3.0 2014.07.31 修正了2.7以为成功实际上未修正成功的问题 并做了一些其他调整
  31. #   V 2.9 2014.07.28 修正了Map不能为:none从2.3版延续过来的傻逼错误
  32. #   V 2.8 2014.07.26 对2.7的小修正 并修改了自定义提示语
  33. #   V 2.7 2014.07.24 修正了事件推进时不刷新周期的问题
  34. #   V 2.6 2014.05.24 修正了日期出现0的BUG
  35. #   V 2.5 2014.04.06 规范化脚本 消除冗余 重建逻辑结构 需要依赖Smomo脚本核心
  36. #   V 2.4 2014.01.31 修正读档时报错的BUG
  37. #   V 2.3 2014.01.29 可以自定义地图窗体的位置
  38. #   V 2.2 2013.12.27 修正Window_MoVMe的错误
  39. #   V 2.1 2013.12.15 修正过卡的BUG
  40. #   V 2.0 2013.10.04 基本重写
  41. #   V 1.0 2013.08.31 公开
  42. #------------------------------------------------------------------------------
  43. # * 声明:
  44. #   本脚本由来自【影月千秋】,使用和转载请保留此信息
  45. #==============================================================================

  46. if $smomo["Core"].nil? || $smomo["Core"] < 1.0
  47.   msgbox "请先安装Smomo脚本核心!"; %x!start http://tinyurl.com/l9kvg2p!
  48. elsif $smomo["Calendar"].nil?
  49. $smomo["Calendar"] = true

  50. #==============================================================================
  51. # ** Smomo::Calendar
  52. #==============================================================================
  53. module Smomo::Calendar
  54.   Menu = false
  55.   # 是否在菜单内显示日历
  56.    # true 使用  false 不使用
  57.    # 如果预设不能满足要求 请自行在下方自定义区更改
  58.   
  59.   Map = :none
  60.   # 是否在地图上显示日历
  61.    # :top 顶部  :bottom 底部  :none 不使用
  62.    # 如果预设不能满足要求 请自行在下方自定义区更改
  63.   
  64.   Use = 13
  65.   # 设定占用开关,只有当此开关打开时,才会计时
  66.    # !打开开关前 请确保下方Speed对应的变量不为0!
  67.   
  68.   Var = 81
  69.   # 设定占用变量的起始编号 会占用以这个号码为开端的连续几个号码对应的游戏变量
  70.   
  71.   # 继续设置需要了解的事实:
  72.   #  脚本内部用一个数字累加计时 然后依次推进到下一单位 把最开始的数字叫计时变量
  73.   
  74.   Speed = 100
  75.   # 设定游戏时间进行速度占用变量,代表经过多少帧后游戏内部计时变量增加一
  76.    # 一般情况下 1秒60帧
  77.    # 再打开Use对应的开关前 请确保这个常量不为0
  78.    # 请确保这个常量不与上面Var的常量(及其包括的范围内的变量)重合

  79.   System = [
  80.     # ["单位", 满多少进一(比最大值大一), 是否以零起始(true/false)],
  81.     ["分", 60, true],
  82.     ["时", 24, true],
  83.     ["日", 9999],
  84.     ["月", 12],
  85.     ["年", 9999],
  86.   ]
  87.   # 设定计时制,最后一个数据的单位与计时变量的单位统一
  88.    # 可以突破公元历法的限制
  89.     # 比如:636号时间线3145纪6887年6月4日 21:39:44:03
  90.    # !这里有几项 上面的Var就会占用几个变量!
  91.    # !从上往下! 单位由小到大 如:分-->时-->日-->月-->年
  92.    # 有的单位允许以0为值 比如 3:00 有的不行 比如 3月1日
  93.     # 默认不允许0值 如果需要允许 请将“以零起始”填为【true】
  94.   
  95.   Start = [00, 7, 1, 1, 0001]
  96.   # 设置游戏起始时间 与上面的单位从上到下依次对应
  97.   
  98.   PeriodName = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
  99.   # 日期的别名 每经过一个周期都会自动推进并显示下一个名字
  100.    # 别名列表长度不固定 可以自行添加或缩短
  101.    
  102.   Start_PeriodName = 6
  103.   # 确定游戏起始时的那个周期的别名是什么 0为第一个别名
  104.    # 一定要用数字来指代 不要用"字符串"
  105.   
  106.   TimeZone = true
  107.   # 是否启用时段功能, 即一个周期内是否有各时段的区分(如:凌晨-中午-黄昏-黑夜)
  108.   
  109.   Zone = [
  110.   # [时段长度, Tone.new(红, 绿, 蓝, 灰), "名称"],
  111.     [120, Tone.new( -75,-100,   0,  75), "夜晚"], # 0...120
  112.     [120, Tone.new(-125,-125, -10, 125), "深夜"], # 120...240
  113.     [120, Tone.new( -75,-100,   0,  75), "黎明"], # 240...360
  114.     [300, Tone.new(   0,   0,   0,   0), "上午"], # 360...660
  115.     [240, Tone.new(  50,  50,  10, -30), "中午"], # 660...900
  116.     [180, Tone.new(   0,   0,   0,   0), "下午"], # 900...1080
  117.     [180, Tone.new(  34, -34, -68, 170), "黄昏"], # 1080...1260
  118.     [180, Tone.new( -75,-100,   0,  75), "夜晚"], # 1260...1440 则1440为周期长度
  119.   ]
  120.   # 设置时段周期内各时段的长度、色调及名称
  121.    # 时段长度以计时变量的单位为单位
  122.   # 到达对应时段时 会自动改变画面的色调
  123.    # 【所有时段的长度加起来就是周期长度!】
  124.    # 【所以,就算不需要使用时段功能,也一定要保证时段长度之和是一个合适的值!】
  125.   # 当一次时段轮回完毕 就会推移到下一个周期(如:周三-->周四)
  126.   
  127.   IndoorMap = [0]
  128.   # 室内地图的ID
  129.    # 处于室内地图时,不会受到时段色调的影响
  130.   
  131.   Format = {
  132.     # 菜单用的格式
  133.     menu: %W!
  134.             <4年>.<2月>.<2日>
  135.             \\I[234]___<Period>
  136.             <2时>:<2分>_<Zone>
  137.           !,
  138.     # 地图用的格式
  139.     map:  %W!
  140.             \\I[234]<2日>日___<2时>:<2分>
  141.           !
  142.   }
  143.   # 输出格式 此处写多少行 游戏内就会依次对应输出多少行
  144.    # 每一行的内部不要使用空格( ),空格用下划线(_)代替
  145.    # 尽量不要使用英文感叹号(!),如果一定要用请在之前加上反斜杠(\!)
  146.    # 使用【<符号>】的形式来代替指定的数据 其他的文字用于修饰
  147.    # 可用的符号
  148.     # 在上面计时制中设定的单位 可以加上一个数字来代表格式化位数
  149.      # 如:<2时>:<2分> 显示 09:33 <时>:<分> 显示 9:33
  150.     # <Period> 当前周期的名字(如:星期三)
  151.     # <Zone>   当前时段的名字(如:早晨)
  152.    # 两个符号必须用两对<>分别括起来 不能写在同一对<>内
  153.     # 允许使用转义字符 但是必须有两个反斜杠
  154.      # 如 显示图标 \I[3] 应写成 \\I[3]
  155. end

  156. #==============================================================================
  157. # 如果你懂脚本,可以在下面调整时间窗口的显示方式
  158. #==============================================================================

  159. #==============================================================================
  160. # ** Scene_Menu 建立菜单场景的窗口
  161. #==============================================================================
  162. class Scene_Menu
  163.   _def_ :start do |*args|
  164.     return unless Smomo::Calendar::Menu
  165.     # 在下面添加自定义内容
  166.     @mocalendar_window = Window_MoMenuCalendar.new(@gold_window)
  167.   end
  168. end
  169. #==============================================================================
  170. # ** Scene_Map 建立地图场景的窗口
  171. #==============================================================================
  172. class Scene_Map
  173.   _def_ :create_all_windows do |*args|
  174.     return if Smomo::Calendar::Map == :none
  175.     # 在下面添加自定义内容
  176.     @mocalendar_window = Window_MoMapCalendar.new
  177.   end
  178.   _def_ :call_menu do |*args|
  179.     return if Smomo::Calendar::Map == :none
  180.     # 在下面添加自定义内容
  181.     @mocalendar_window.contents.clear
  182.   end
  183. end
  184. #============================================================================
  185. # ** Window_MoMenuCalendar 菜单画面中,显示当前游戏内部虚拟日历的窗口
  186. #============================================================================
  187. class Window_MoMenuCalendar < Window_Base
  188.   include Smomo::Calendar
  189.   
  190.   def initialize(gold_window)
  191.     unless $game_switches[Use]
  192.       super(0, 0, 1, 1)
  193.       self.opacity = 0
  194.       return
  195.     end
  196.     Smomo::Calendar.ensure_time_legal
  197.     Smomo::Calendar.check_period_and_zone
  198.     height = Format[:menu].size * 30 + 20
  199.     super(0, gold_window.y - height, gold_window.width, height)
  200.     format = Smomo.deep_clone(Format[:menu])
  201.     format.each_with_index do |t, l|
  202.       t.gsub!(/_/){" "}
  203.       System.each_with_index do |(u, m), i|
  204.         t.gsub!(/<(\d*)#{u}>/){
  205.           format("%0#{$1 ? $1.to_i : nil}d", $game_variables[Var + i])
  206.         }
  207.       end
  208.       t.gsub!(/<Period>/){"#{PeriodName[Smomo::Calendar.prd]}"}
  209.       t.gsub!(/<Zone>/){"#{Smomo::Calendar.zone}"}
  210.       draw_text_ex(0, l * 30, t)
  211.     end
  212.   end
  213. end
  214. #============================================================================
  215. # ** Window_MoMapCalendar 地图画面中,显示当前游戏内部虚拟日历的窗口
  216. #                         但本质上是一个精灵
  217. #============================================================================
  218. class Window_MoMapCalendar < Window_Base
  219.   include Smomo::Calendar
  220.   
  221.   def initialize
  222.     height = Format[:map].size * 30 + 10
  223.     @sprite = Sprite.new
  224.     @sprite.y = Smomo::Calendar::Map == :top ? 0 : Graphics.height - height
  225.     @sprite.bitmap = Bitmap.new(Graphics.width, height)
  226.     @use = true
  227.     update
  228.     refresh
  229.   end
  230.   
  231.   def update
  232.     unless @use == $game_switches[Use]
  233.       @use = $game_switches[Use]
  234.       @sprite.x = @use ? 0 : Graphics.width
  235.       refresh
  236.     else
  237.       refresh if @use && Graphics.frame_count % $game_variables[Speed] == 0 ||
  238.       $game_map.need_refresh
  239.     end
  240.   end
  241.   
  242.   def refresh
  243.     Smomo::Calendar.ensure_time_legal
  244.     Smomo::Calendar.check_period_and_zone
  245.     contents.clear
  246.     contents.gradient_fill_rect(400, 0, 200, @sprite.width,
  247.     Color.new(30, 30, 30), Color.new(0, 0, 0, 0))
  248.     format = Smomo.deep_clone(Format[:map])
  249.     format.each_with_index do |t, l|
  250.       t.gsub!(/_/){" "}
  251.       System.each_with_index do |(u, m), i|
  252.         t.gsub!(/<(\d*)#{u}>/){
  253.           format("%0#{$1 ? $1.to_i : nil}d", $game_variables[Var + i])
  254.         }
  255.       end
  256.       t.gsub!(/<Period>/){"#{PeriodName[Smomo::Calendar.prd]}"}
  257.       t.gsub!(/<Zone>/){"#{Smomo::Calendar.zone}"}
  258.       draw_text_ex(410, l * 30 + 5, t)
  259.     end
  260.   end
  261.   #------------------------------------------------------------------------
  262.   # * 偷梁换柱 如果不明白这段的意义 请勿随意删除
  263.   #------------------------------------------------------------------------
  264.   def contents
  265.     @sprite.bitmap
  266.   end
  267.   def windowskin
  268.     Cache.system("Window")
  269.   end
  270. end
  271. #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+#
  272. #------------------------------------------------------------------------------#
  273.                                "请勿跨过这块区域"
  274. #------------------------------------------------------------------------------#
  275. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=#

  276. #==============================================================================
  277. # ** Smomo::Calendar
  278. #==============================================================================
  279. module Smomo::Calendar
  280.   # 预处理
  281.   PeriodSize = Zone.inject(0){|s, (l)| s + l}
  282.   Zone.each_with_index{|z, i| z[0] += i == 0 ? 0 : Zone[i - 1][0]}
  283.   _ = Smomo.deep_clone(Zone)
  284.   _.each_with_index{|z, i| Zone[i][0] = (i == 0 ? 0 : _[i - 1][0])...z[0]}
  285.   class << self
  286.     attr_reader :zone, :prd, :ticking
  287.     attr_accessor :period
  288.     define_method(:data){[@zone, @tone, @need_change, @period, @prd]}
  289.     define_method(:data=){|d| @zone, @tone, @need_change, @period, @prd = d}
  290.     define_method(:function){|type| type == :all ? data : eval(%!@#{type}!)}
  291.     # 初始化
  292.     def ini
  293.       @ticking = true
  294.       System.each_index{|i| $game_variables[Var + i] = Start[i]}
  295.       @ticking = false
  296.       [url=home.php?mod=space&uid=43863]@zone[/url] = ""
  297.       @tone = Tone.new(0, 0, 0, 0)
  298.       @need_change = false
  299.       @period = init_period
  300.       @prd = Start_PeriodName
  301.       check_period_and_zone
  302.     end
  303.     # 初始化周期
  304.     def init_period
  305.       sta = Start.reverse
  306.       sta.each_with_index do |n, i|
  307.         next if i == sta.size - 1
  308.         sta[i + 1] += n * System.reverse[i + 1][1]
  309.       end
  310.       sta.reverse[0] % PeriodSize
  311.     end
  312.     # 计时
  313.     def i_look_into_the_sky_as_time_passes_by
  314.       return unless $game_switches[Use]
  315.       return if $game_message.visible
  316.       return unless Graphics.frame_count % $game_variables[Speed] == 0
  317.       # 如果在这里报错 一定是你没有设置Speed所对应的变量的值
  318.       @ticking = true
  319.       $game_variables[Var] += 1
  320.       @period += 1
  321.       ensure_time_legal
  322.       ensure_period_legal
  323.       check_period_and_zone
  324.       change_tone if TimeZone
  325.       @ticking = false
  326.     end
  327.     # 确保变量在范围内
  328.     def ensure_time_legal
  329.       @ticking = true
  330.       System.each_with_index do |(u, m, o), i|
  331.         while $game_variables[Var + i] > m - (o ? 1 : 0)
  332.           $game_variables[Var + i] -= m
  333.           $game_variables[Var + i + 1] += 1
  334.         end
  335.         while $game_variables[Var + i] < 1 - (o ? 1 : 0)
  336.           $game_variables[Var + i] += m
  337.           $game_variables[Var + i + 1] -= 1
  338.         end
  339.       end
  340.       @ticking = false
  341.     end
  342.     # 确保时段在范围内
  343.     def ensure_period_legal
  344.       @prd += (@period = 0) + 1 if @period >= PeriodSize
  345.       @prd = 0 if @prd >= PeriodName.size
  346.     end
  347.     # 检查周期别名和时段
  348.     def check_period_and_zone
  349.       tone, @zone = Zone.find{|(r, t, n)| r.include?(@period)}[1, 2]
  350.       @tone == tone ? nil : [@tone = tone, @need_change = true]
  351.     end
  352.     # 改变画面色调
  353.     def change_tone(pt = false)
  354.       return unless @need_change || pt
  355.       @need_change = false
  356.       if IndoorMap.include?($game_map.map_id)
  357.         $game_map.screen.start_tone_change(Tone.new(0, 0, 0, 0), 0)
  358.       else
  359.         $game_map.screen.start_tone_change(@tone, pt ? 0 : 60)
  360.       end
  361.     end
  362.   end
  363. end
  364. #==============================================================================
  365. # ** Smomo.calendar(*a, &b)
  366. #==============================================================================
  367. def Smomo.calendar(*a, &b)
  368.   Smomo::Calendar.function(*a, &b)
  369. end
  370. #==============================================================================
  371. # ** Game_Switches
  372. #==============================================================================
  373. class Game_Switches
  374.   _def_ :on_change do
  375.     Smomo::Calendar.change_tone
  376.   end
  377. end
  378. #==============================================================================
  379. # ** Game_Variables
  380. #==============================================================================
  381. class Game_Variables
  382.   _def_ :[]=, :c do |old, variable_id, value|
  383.     if Smomo::Calendar.ticking
  384.       old.call(variable_id, value)
  385.     else
  386.       min = Smomo::Calendar::Var
  387.       max = min + Smomo::Calendar::System.size - 1
  388.       if variable_id.between?(min, max)
  389.         Smomo::Calendar.period += value - @data[variable_id]
  390.         old.call(variable_id, value)
  391.         Smomo::Calendar.ensure_time_legal
  392.         Smomo::Calendar.ensure_period_legal
  393.         Smomo::Calendar.check_period_and_zone
  394.         Smomo::Calendar.change_tone
  395.       else
  396.         old.call(variable_id, value)
  397.       end
  398.     end
  399.   end
  400. end
  401. #==============================================================================
  402. # ** Scene_Map
  403. #==============================================================================
  404. class Scene_Map
  405.   _def_ :update do |*args|
  406.     Smomo::Calendar.i_look_into_the_sky_as_time_passes_by
  407.   end
  408.   _def_ :post_transfer, :b do |*args| Smomo::Calendar.change_tone(true) end
  409. end
  410. #==============================================================================
  411. # ** DataManager
  412. #==============================================================================
  413. class << DataManager
  414.   _def_ :setup_new_game do Smomo::Calendar.ini end
  415.   _def_ :make_save_contents, :v do |contents, *args|
  416.     contents[:mocalendar] = Smomo::Calendar.data
  417.     contents
  418.   end
  419.   _def_ :extract_save_contents do |contents, *args|
  420.     Smomo::Calendar.data = contents[:mocalendar]
  421.   end
  422. end

  423. else # if $smomo
  424.   msgbox "请不要重复加载此脚本 : )\n【虚拟日历】"
  425. end
  426. #==============================================================================#
  427. #=====                        =================================================#
  428.             "脚 本 尾"
  429. #=====                        =================================================#
  430. #==============================================================================#
复制代码
roguelike求生RPG研发中....

Lv4.逐梦者 (版主)

百合控

梦石
0
星屑
6543
在线时间
1275 小时
注册时间
2013-8-21
帖子
3657

开拓者

2
发表于 2014-9-30 19:33:18 | 只看该作者
首先……最新版本在此

其次是针对你的问题所作的补丁,贴在原脚本以下

RUBY 代码复制
  1. #==============================================================================
  2. # ** 虚拟日历·定制插件 2014.09.30
  3. #==============================================================================
  4.  
  5. #============================================================================
  6. # ** Window_MoMenuCalendar 开关控制菜单画面是否显示时间
  7. #  这一段是用于菜单画面的 不需要的话直接删掉
  8. #============================================================================
  9. class Window_MoMenuCalendar
  10.   _def_ :initialize, :if do |*args|
  11.     菜单开关ID = 10
  12.     # 正在计时中 且该开关打开 才显示
  13.     unless $game_switches[菜单开关ID]
  14.       super(0, 0, 1, 1)
  15.       self.opacity = 0
  16.       return false
  17.     end
  18.     true
  19.   end
  20. end
  21.  
  22. #============================================================================
  23. # ** Window_MoMapCalendar 开关控制地图画面是否显示时间
  24. #  这一段是用于地图画面的 不需要的话直接删掉
  25. #============================================================================
  26. class Window_MoMapCalendar
  27.   _def_ :update, :if do |*args|
  28.     地图开关ID = 11
  29.     # 正在计时中 且该开关打开 才显示
  30.     if $game_switches[地图开关ID]
  31.       @sprite.visible = true unless @sprite.visible
  32.     else
  33.       @sprite.visible = false if @sprite.visible
  34.       return false
  35.     end
  36.     true
  37.   end
  38. end

点评

时间虽然有点久... 但是我想问~她新脚本的设定上我这里还是有问题 return unless Graphics.frame_count % $game_variables[Speed] == 0 我怎么设定这里一定都会报错  发表于 2015-9-8 00:44
汗 半個多月沒上了 剛準備去玩紅警來著 看到新提醒了  发表于 2014-9-30 20:00
酷爱上Q啦  发表于 2014-9-30 19:58

评分

参与人数 2星屑 +132 梦石 +1 收起 理由
VIPArcher + 132 浴巾大美女么么哒~
taroxd + 1 认可答案

查看全部评分

萌新瑟瑟发抖
看到我请叫我去干活
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-26 05:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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