Project1

标题: 如何给这个脚本加上一个开关? [打印本页]

作者: xzqcm111    时间: 2011-4-17 23:38
标题: 如何给这个脚本加上一个开关?
比如给90号开关打开时,此脚本不起作用。以下脚本代码
  1. #地图名及坐标显示
  2. #==============================================================================
  3. # ■ Window_Pos
  4. #==============================================================================

  5. class Window_Pos < Window_Base
  6. #--------------------------------------------------------------------------
  7. # ● 初始化
  8. #--------------------------------------------------------------------------
  9. def initialize
  10.    super(0, 0, 122, 52)
  11.    self.z = 151
  12.    self.contents.font.size = 20
  13.    refresh
  14. end
  15. #--------------------------------------------------------------------------
  16. # ● 刷新
  17. #--------------------------------------------------------------------------
  18. def refresh
  19.    self.contents.clear
  20.    self.contents.font.color = system_color
  21.    @x,@y = $game_player.x,$game_player.y
  22.    self.contents.draw_text(0, 0, 90, 20, "(#{@x},#{@y})", 1)
  23. end
  24. #--------------------------------------------------------------------------
  25. # ● 更新
  26. #--------------------------------------------------------------------------
  27. def update
  28.    return if $game_player.x == @x and $game_player.y == @y
  29.    refresh
  30. end
  31. end

  32. #==============================================================================
  33. # ■ Window_MapName
  34. #==============================================================================

  35. class Window_MapName < Window_Base
  36. #--------------------------------------------------------------------------
  37. # ● 初始化
  38. #--------------------------------------------------------------------------
  39. def initialize
  40.    @map_id = $game_map.map_id
  41.    super(0, 0, 182, 52)
  42.    self.contents.font.size = 20
  43.    self.z = 151
  44.    refresh
  45. end
  46. #--------------------------------------------------------------------------
  47. # ● 刷新
  48. #--------------------------------------------------------------------------
  49. def refresh
  50.    self.opacity = 255
  51.    self.contents_opacity = 255
  52.    name = $data_mapinfos[@map_id].name
  53.    width = self.contents.text_size(name).width
  54.    height = self.contents.text_size(name).height
  55.    self.width = width + 32
  56.    self.height = height + 32
  57.    self.contents = Bitmap.new(width, height)
  58.    self.contents.font.size = 20
  59.    self.x = (Graphics.width - self.width) / 2
  60.    self.y = (Graphics.height - self.height) / 2
  61.    self.contents.font.color = system_color
  62.    self.contents.draw_text(0, 0, width, 20, name, 1)
  63. end
  64. #--------------------------------------------------------------------------
  65. # ● 更新
  66. #--------------------------------------------------------------------------
  67. def update
  68.    if $game_map.map_id != @map_id
  69.      @map_id = $game_map.map_id
  70.      refresh
  71.      self.opacity = 255
  72.      self.contents_opacity = 255
  73.    end
  74.    return if self.opacity == 0
  75.    self.opacity -= 5
  76.    self.contents_opacity -= 5
  77. end

  78. end

  79. class Scene_Title < Scene_Base
  80. #--------------------------------------------------------------------------
  81. # ● 数据库载入
  82. #--------------------------------------------------------------------------
  83. alias old_ld load_database
  84. def load_database
  85.    old_ld
  86.    $data_mapinfos       = load_data("Data/MapInfos.rvdata")
  87. end
  88. end

  89. class Scene_Map < Scene_Base
  90. #--------------------------------------------------------------------------
  91. # ● 开始
  92. #--------------------------------------------------------------------------
  93. alias old_start start
  94. def start
  95.    old_start
  96.    @pos_window = Window_Pos.new
  97.    @mapname_window = Window_MapName.new
  98. end
  99. #--------------------------------------------------------------------------
  100. # ● 结束
  101. #--------------------------------------------------------------------------
  102. alias old_ter terminate
  103. def terminate
  104.    old_ter
  105.    @pos_window.dispose
  106.    @mapname_window.dispose
  107. end
  108. #--------------------------------------------------------------------------
  109. # ● 更新
  110. #--------------------------------------------------------------------------
  111. alias old_update update
  112. def update
  113.    old_update
  114.    @pos_window.update
  115.    @mapname_window.update
  116. end
  117. end
复制代码
dsu_plus_rewardpost_czw
作者: killkill2298    时间: 2011-4-18 13:28
本帖最后由 killkill2298 于 2011-4-18 13:30 编辑

好像置顶帖里面有可以用开关控制的地图名称显示脚本

这个要改的话,在所有def refresh后面一行添加一句:
if $game_switches[开关ID] = true then end
应该可以吧

未测试,自己试下
作者: xzqcm111    时间: 2011-4-18 21:46

经测试不行。。。。算了,我直接去掉了这个脚本,公共事件显示地图名了,坐标那个东西要不要无所谓- -||


xzqcm111于2011-4-18 21:49补充以下内容:
ruby的标签跳转指令是什么啊? 其实可以在最后加个标签然后再加个返回的跳转就好了吧。
作者: trentswd    时间: 2011-4-23 07:46
  1. def update
  2. if $game_switches[开关ID] == true
  3.    if $game_map.map_id != @map_id
  4.      @map_id = $game_map.map_id
  5.      refresh
  6.      self.opacity = 255
  7.      self.contents_opacity = 255
  8.    end
  9.    return if self.opacity == 0
  10.    self.opacity -= 5
  11.    self.contents_opacity -= 5
  12. else
  13. self.opacity =0 if self.opacity != 0
  14. end
  15. end
复制代码
好像就这么简单,没有测试,不行再说
ruby好像没有goto……




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1