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

Project1

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

[已经过期] 迷你地圖腳本,存檔後新增地圖進入出錯,求解

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
448 小时
注册时间
2011-10-9
帖子
184
跳转到指定楼层
 楼主| 发表于 2013-2-23 16:46:28 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x

如果存檔後又新增了一個空白地圖
那麼讀檔進入地圖就會報錯:

-----------------------------------------------------------------------
腳本 '迷你地圖' 的第 125 行發生了 NoMethodError .

undefined method `show_minimap?' for nil:NilClass
-----------------------------------------------------------------------

許多國外玩家也有這項問題,腳本如下
  1. if true
  2. #~   if false

  3. #===============================================================
  4. # ● [VX] ◦ MiniMap ◦ □
  5. # * Plug N Play Minimap (Don't need image~)
  6. # ◦ by Woratana [[email protected]]


  7. module MiniMap
  8.   #===========================================================================
  9.   # [START] MINIMAP SCRIPT SETUP PART
  10.   #---------------------------------------------------------------------------
  11.   SWITCH_NO_MINIMAP = 6 # 打開這個不顯示迷你地圖
  12.    
  13.   MAP_RECT = [539,22, 96, 96] # 迷你地圖尺寸和位置[x.y.長.寬] 要12的倍數 538 22 96 96
  14.   # [X, Y, Width, Height]
  15.   # 你可以呼叫腳本來改他
  16.   # $game_system.minimap = [X, Y, Width, Height]
  17.   # $game_system.minimap = [5, 5,84,84]  

  18.   MAP_Z = 0 # Minimap's Z-協調
  19.   #增加這個數字,如果是小地圖上顯示下面的一些對象的問題。

  20.   GRID_SIZE = 6 #(縮放倍率) 建議超過3    6
  21.   
  22.   MINIMAP_BORDER_COLOR = Color.new(40,180,250,130) # 迷你地圖邊框顏色
  23.   # Color.new(Red, Green, Blue, Opacity)
  24.   MINIMAP_BORDER_SIZE = 1 #邊框厚度
  25.   #-----------------------------------------------------------------------------------------------------------------                             
  26.   FOREGROUND_COLOR = Color.new(235,245,255, 100) #可通行顏色
  27.   BACKGROUND_COLOR = Color.new(0, 5, 10, 120) #無法通行顏色  
  28.   #-----------------------------------------------------------------------------------------------------------------  
  29.   USE_OUTLINE_EVENT = true                       # 是否顯示事件點
  30.   EVENT_OUTLINE_COLOR = Color.new(0,0,0, 255)  # 事件點邊框顏色
  31.   USE_OUTLINE_PLAYER = true                      # 是否顯示玩家
  32.   PLAYER_OUTLINE_COLOR = Color.new(0, 40,180, 255) # 角色邊框顏色
  33.   PLAYER_COLOR = Color.new(0, 110, 250, 255)    # 玩家顏色 藍色
  34.   #-----------------------------------------------------------------------------------------------------------------
  35.   
  36.   OBJECT_COLOR = {} # 不要動這個
  37.   #===============================================================
  38.   OBJECT_COLOR['NPC'] = Color.new(0,170,95,255)  #綠色
  39.   OBJECT_COLOR['敵人'] = Color.new(220,0,0,255) #紅色
  40.   OBJECT_COLOR['傳送'] = Color.new(0,255,255,255)  #青色
  41.   OBJECT_COLOR['存檔'] = Color.new(150,60,250,255) #紫色
  42.   OBJECT_COLOR['日誌'] = Color.new(255,255,255,255) #白色
  43.   OBJECT_COLOR['其它'] = Color.new(255,200,0,255) #金色  

  44.   #世界地圖用
  45.   OBJECT_COLOR['城鎮'] = Color.new(35,95,170,255) #藍色
  46.   OBJECT_COLOR['關卡'] = Color.new(170,35,35,255)  #紅色
  47.   OBJECT_COLOR['通道'] = Color.new(255,204,32,255) #黃色
  48.   OBJECT_COLOR['特殊'] = Color.new(150,150,150,255) #灰色
  49.   
  50.   #===========================================================================
  51.   #* [可選]標籤:
  52.   #------------------------------------------------- --------------------------
  53.   #更改為禁用小地圖小地圖和事件的顯示關鍵字的〜
  54.   #------------------------------------------------- ----------------------
  55.   TAG_NO_MINIMAP ='X'#標記為禁用小地圖
  56.   TAG_EVENT ='點'#標記的小地圖上顯示事件
  57.   #---------------------------------------------------------------------------
  58.   #---------------------------------------------------------------------------
  59.   # [END] MINIMAP SCRIPT SETUP PART
  60.   #===========================================================================
  61.   
  62.   def self.refresh
  63.     if $scene.is_a?(Scene_Map)
  64.       $scene.spriteset.minimap.refresh
  65.     end
  66.   end
  67.   
  68.   def self.update_object
  69.     if $scene.is_a?(Scene_Map)
  70.       $scene.spriteset.minimap.update_object_list
  71.     end
  72.   end
  73. end

  74. #==============================================================================
  75. # ?RPG::MapInfo
  76. #==============================================================================
  77. class RPG::MapInfo
  78.   def name
  79.     return @name.gsub(/\[.*\]/) { }
  80.   end

  81.   def original_name
  82.     return @name
  83.   end

  84.   def show_minimap?
  85.     return [email protected]?(MiniMap::TAG_NO_MINIMAP)
  86.   end
  87. end
  88. #==============================================================================
  89. # ?Game_System
  90. #==============================================================================
  91. class Game_System
  92.   attr_accessor :minimap
  93.   alias wora_minimap_gamsys_ini initialize
  94.   
  95.   def initialize
  96.     wora_minimap_gamsys_ini
  97.     @minimap = MiniMap::MAP_RECT
  98.   end
  99.   
  100.   def show_minimap
  101.     return !$game_switches[MiniMap::SWITCH_NO_MINIMAP]
  102.   end
  103. end
  104. #==============================================================================
  105. # ?Game_Map
  106. #==============================================================================
  107. class Game_Map
  108.   alias wora_minimap_gammap_setup setup
  109.   def setup(map_id)
  110.     wora_minimap_gammap_setup(map_id)
  111.     @db_info = load_data('Data/MapInfos.rvdata') if @db_info.nil?
  112.     @map_info = @db_info[map_id]
  113.   end
  114.   
  115.   def show_minimap?
  116.     return @map_info.show_minimap?
  117.   end
  118. end
  119. #==============================================================================
  120. # ?Game_Event
  121. #==============================================================================
  122. class Game_Event < Game_Character
  123.   def mm_comment?(comment, return_comment = false )
  124.     if [email protected]?
  125.       for i in [email protected] - 1
  126.         next if @list[i].code != 108
  127.         if @list[i].parameters[0].include?(comment)
  128.           return @list[i].parameters[0] if return_comment
  129.           return true
  130.         end
  131.       end
  132.     end
  133.     return '' if return_comment
  134.     return false
  135.   end
  136. end
  137. #==============================================================================
  138. # ?Game_MiniMap
  139. #------------------------------------------------------------------------------
  140. class Game_MiniMap
  141.   def initialize(tilemap)
  142.     @tilemap = tilemap
  143.     refresh
  144.   end

  145.   def dispose
  146.     @border.bitmap.dispose
  147.     @border.dispose
  148.     @map_sprite.bitmap.dispose
  149.     @map_sprite.dispose
  150.     @object_sprite.bitmap.dispose
  151.     @object_sprite.dispose
  152.     @position_sprite.bitmap.dispose
  153.     @position_sprite.dispose
  154.   end

  155.   def visible
  156.     return @map_sprite.visible
  157.   end

  158.   def visible=(value)
  159.     @map_sprite.visible = value
  160.     @object_sprite.visible = value
  161.     @position_sprite.visible = value
  162.     @border.visible = value
  163.   end

  164.   def refresh
  165.     @mmr = $game_system.minimap
  166.     map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
  167.     grid_size = [MiniMap::GRID_SIZE, 1].max

  168.     @x = 0
  169.     @y = 0
  170.     @size = [map_rect.width / grid_size, map_rect.height / grid_size]

  171.     @border = Sprite.new
  172.     @border.x = map_rect.x - MiniMap::MINIMAP_BORDER_SIZE
  173.     @border.y = map_rect.y - MiniMap::MINIMAP_BORDER_SIZE
  174.     b_width = map_rect.width + (MiniMap::MINIMAP_BORDER_SIZE * 2)
  175.     b_height = map_rect.height + (MiniMap::MINIMAP_BORDER_SIZE * 2)
  176.     @border.bitmap = Bitmap.new(b_width, b_height)
  177.     @border.bitmap.fill_rect(@border.bitmap.rect, MiniMap::MINIMAP_BORDER_COLOR)
  178.     @border.bitmap.clear_rect(MiniMap::MINIMAP_BORDER_SIZE, MiniMap::MINIMAP_BORDER_SIZE,
  179.     @border.bitmap.width - (MiniMap::MINIMAP_BORDER_SIZE * 2),
  180.     @border.bitmap.height - (MiniMap::MINIMAP_BORDER_SIZE * 2))
  181.    
  182.     @map_sprite = Sprite.new
  183.     @map_sprite.x = map_rect.x
  184.     @map_sprite.y = map_rect.y
  185.     @map_sprite.z = MiniMap::MAP_Z
  186.     bitmap_width = $game_map.width * grid_size + map_rect.width
  187.     bitmap_height = $game_map.height * grid_size + map_rect.height
  188.     @map_sprite.bitmap = Bitmap.new(bitmap_width, bitmap_height)
  189.     @map_sprite.src_rect = map_rect

  190.     @object_sprite = Sprite.new
  191.     @object_sprite.x = map_rect.x
  192.     @object_sprite.y = map_rect.y
  193.     @object_sprite.z = MiniMap::MAP_Z + 1
  194.     @object_sprite.bitmap = Bitmap.new(bitmap_width, bitmap_height)
  195.     @object_sprite.src_rect = map_rect

  196.     @position_sprite = Sprite_Base.new
  197.     @position_sprite.x = map_rect.x + @size[0] / 2 * grid_size
  198.     @position_sprite.y = map_rect.y + @size[1] / 2 * grid_size
  199.     @position_sprite.z = MiniMap::MAP_Z + 2
  200.    
  201.     bitmap = Bitmap.new(grid_size, grid_size)
  202.     # Player's Outline
  203.     if MiniMap::USE_OUTLINE_PLAYER and MiniMap::GRID_SIZE >= 3
  204.       bitmap.fill_rect(bitmap.rect, MiniMap::PLAYER_OUTLINE_COLOR)
  205.       brect = Rect.new(bitmap.rect.x + 1, bitmap.rect.y + 1, bitmap.rect.width - 2,
  206.         bitmap.rect.height - 2)
  207.       bitmap.clear_rect(brect)
  208.     else
  209.       brect = bitmap.rect
  210.     end
  211.    
  212.     bitmap.fill_rect(brect, MiniMap::PLAYER_COLOR)
  213.     @position_sprite.bitmap = bitmap

  214.     draw_map
  215.     update_object_list
  216.     draw_object
  217.     update_position
  218.   end

  219.   def draw_map
  220.     bitmap = @map_sprite.bitmap
  221.     bitmap.fill_rect(bitmap.rect, MiniMap::BACKGROUND_COLOR)
  222.     map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
  223.     grid_size = [MiniMap::GRID_SIZE, 1].max
  224.    
  225.     $game_map.width.times do |i|
  226.       $game_map.height.times do |j|
  227.         if !$game_map.passable?(i, j)
  228.           next
  229.         end
  230.         rect = Rect.new(map_rect.width / 2 + grid_size * i,
  231.           map_rect.height / 2 + grid_size * j,
  232.           grid_size, grid_size)
  233.         if grid_size >= 3
  234.           if !$game_map.passable?(i, j)
  235.             rect.height -= 1
  236.             rect.x += 1
  237.             rect.width -= 1
  238.             rect.width -= 1
  239.             rect.y += 1
  240.             rect.height -= 1
  241.           end
  242.         end
  243.         bitmap.fill_rect(rect, MiniMap::FOREGROUND_COLOR)
  244.       end
  245.     end
  246.   end

  247.   def update_object_list
  248.     @object_list = {}
  249.     $game_map.events.values.each do |e|
  250.       comment = e.mm_comment?(MiniMap::TAG_EVENT, true)
  251.       if comment != ''
  252.         type = comment.gsub(/#{MiniMap::TAG_EVENT}/){}.gsub(/\s+/){}
  253.         @object_list[type] = [] if @object_list[type].nil?
  254.         @object_list[type] << e
  255.       end
  256.     end
  257.   end

  258.   def draw_object
  259.     bitmap = @object_sprite.bitmap
  260.     bitmap.clear
  261.     map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
  262.     grid_size = [MiniMap::GRID_SIZE, 1].max
  263.     rect = Rect.new(0, 0, grid_size, grid_size)
  264.     mw = map_rect.width / 2
  265.     mh = map_rect.height / 2

  266.     @object_list.each do |key, events|
  267.       color = MiniMap::OBJECT_COLOR[key]
  268.       next if events.nil? or color.nil?
  269.       events.each do |obj|
  270.         if !obj.character_name.empty?
  271.           rect.x = mw + obj.real_x * grid_size / 256
  272.           rect.y = mh + obj.real_y * grid_size / 256
  273.           # Event's Outline
  274.           if MiniMap::USE_OUTLINE_EVENT and MiniMap::GRID_SIZE >= 3
  275.             bitmap.fill_rect(rect, MiniMap::EVENT_OUTLINE_COLOR)
  276.             brect = Rect.new(rect.x + 1, rect.y + 1, rect.width - 2,
  277.             rect.height - 2)
  278.             bitmap.clear_rect(brect)
  279.           else
  280.             brect = bitmap.rect
  281.           end
  282.           bitmap.fill_rect(brect, color)
  283.         end
  284.       end
  285.     end
  286.   end

  287.   def update
  288.     if @mmr != $game_system.minimap
  289.       dispose
  290.       refresh
  291.     end
  292.     draw_object
  293.     update_position
  294.     if @map_sprite.visible
  295.       @map_sprite.update
  296.       @object_sprite.update
  297.       @position_sprite.update
  298.     end
  299.   end

  300.   def update_position
  301.     map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
  302.     grid_size = [MiniMap::GRID_SIZE, 1].max
  303.     sx = $game_player.real_x * grid_size / 256
  304.     sy = $game_player.real_y * grid_size / 256
  305.     @map_sprite.src_rect.x = sx
  306.     @map_sprite.src_rect.y = sy
  307.     @object_sprite.src_rect.x = sx
  308.     @object_sprite.src_rect.y = sy
  309.   end
  310. end
  311. #==============================================================================
  312. # ?Spriteset_Map
  313. #------------------------------------------------------------------------------
  314. class Spriteset_Map
  315.   attr_reader :minimap
  316.   alias wora_minimap_sprsetmap_ini initialize
  317.   alias wora_minimap_sprsetmap_dis dispose
  318.   alias wora_minimap_sprsetmap_upd update
  319.   
  320.   def initialize
  321.     wora_minimap_sprsetmap_ini
  322.     if $game_map.show_minimap?
  323.       @minimap = Game_MiniMap.new(@tilemap)
  324.       $game_system.show_minimap = true if $game_system.show_minimap.nil?
  325.       @minimap.visible = $game_system.show_minimap
  326.     end
  327.   end
  328.   
  329.   def dispose
  330.     @minimap.dispose if [email protected]?
  331.     wora_minimap_sprsetmap_dis
  332.   end

  333.   def update
  334.     if [email protected]?
  335.       if $game_system.show_minimap
  336.         @minimap.visible = true
  337.         @minimap.update
  338.       else
  339.         @minimap.visible = false
  340.       end
  341.     end
  342.     wora_minimap_sprsetmap_upd
  343.   end
  344. end
  345. #==============================================================================
  346. # ?Scene_Map
  347. #------------------------------------------------------------------------------
  348. class Scene_Map < Scene_Base
  349.   attr_reader :spriteset
  350. end
  351. end
复制代码

点评

去除本脚本,继续制作游戏,制作完成后再加回来即可。  发表于 2013-2-25 18:29

Lv2.观梦者

梦石
0
星屑
655
在线时间
194 小时
注册时间
2012-6-1
帖子
720
3
发表于 2013-2-26 22:41:53 | 只看该作者
小地图的功能并不是太重要
最后加好了
死亡
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
448 小时
注册时间
2011-10-9
帖子
184
2
 楼主| 发表于 2013-2-26 22:27:39 | 只看该作者
本帖最后由 冷徹心扉 于 2013-2-26 22:28 编辑

回P叔:
側試過暫時移除掉整個腳本,但麻煩的是:

只要曾經在運行這個腳本的情況下存過檔
之後只要藉由這個腳本讀取該檔就會錯誤(地圖建立日期比存檔新時)
調用開關、另存新檔後置入腳本都沒有用

不是 NoMethodError .
undefined method `show_minimap?' for nil:NilClass

就是 NoMethodError .
undefined method [] for nil:NilClass
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
655
在线时间
194 小时
注册时间
2012-6-1
帖子
720
1
发表于 2013-2-24 07:15:07 | 只看该作者
目测你不需要改啊
发型游戏后玩家又不会去改地图

点评

而且長篇章節式發佈的遊戲沒辦法這樣做  发表于 2013-2-26 22:24
我指的是測試時必須繼承的許多資料,(例如魔物圖鑑、關卡結束後應該擁有哪些道具)重新開始就得重新蒐集了  发表于 2013-2-26 22:23
您可以直接更改主角位置啊 况且这个脚本可以最后加嘛  发表于 2013-2-24 21:41
您誤會了,製作遊戲總不可能每次測試遊戲都重新開始吧?  发表于 2013-2-24 18:50
死亡
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-24 10:28

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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