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

Project1

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

[已经解决] 太奇怪了,为什么之前没报错的脚本现在就报错了

[复制链接]

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

跳转到指定楼层
1
发表于 2014-12-3 21:37:09 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
放新工程也没用
总有那么几个像遇鬼了似的,之前明明可以运行的,过了几天就突然报错了,放新工程也会报错。


这个合成脚本当时明明可以用的,现在就用不了了。   有 for item_forge in @forge_item的地方都报错。



RUBY 代码复制
  1. #==============================================================================
  2. # ★ Item_Transmute
  3. #------------------------------------------------------------------------------
  4. #  配方不公开的物品合成 
  5. #  By Summoner
  6. #==============================================================================
  7. #
  8. # 本脚本以 知识共享署名-非商业性使用 3.0 Unported 许可协议进行许可。
  9. # 详见 [url]http://creativecommons.org/licenses/by-nc/3.0/[/url]
  10. #
  11. #==============================================================================
  12. #  
  13. # 这是一个配方不公开的物品合成,也就是说什么材料可以合成什么物品玩家在
  14. # 游戏中的合成界面是不能直接看到的。由于物品的合成配方不是公开的,所以
  15. # 玩家需要通过自己探索或从NPC处得到合成配方(当然看攻略也是一种可能)
  16. #  
  17. # 例如M&M中的配药水,Diablo II的盒子,NWV中的铁匠铺、Wizard Lab……
  18. #  
  19. # 冲突可能性:基本上是添加新的内容,冲突可能性较小
  20. #
  21. # 可扩展性:可以加强、扩展的东西应该很多。
  22. #   例如:合成需要花费GP、SP甚至XP,合成需要特定器具,合成失败受到伤害,
  23. #   某些物品的几率合成、物品图鉴等等。
  24. #
  25. #   有的东西已经注释清楚了,搞懂原理的话,根据自己需要改起来也不会很麻烦。
  26. #
  27. #   个人一下子没时间实现这些,欢迎大家多多修改分享。
  28. #
  29. # 使用方法:在事件中使用脚本$scene = Scene_Compose.new,然后等待2帧
  30. #
  31. #
  32. #==============================================================================
  33.  
  34. # 若合成失败(无匹配的配方)物品是否失去
  35. $Ingredient_Lost_When_Fail = true
  36.  
  37. # 合成成功/失败SE  
  38. # 若不使用SE请设置为“""”(不含外引号)
  39. $SE_Compose_Successful = "Audio/SE/109-Heal05"  
  40. $SE_Compose_Failed = "Audio/SE/117-Fire01"
  41.  
  42. #=============================================================================
  43. # ■ 配方及补充的定义
  44. #-----------------------------------------------------------------------------
  45. # Game_System
  46. #=============================================================================
  47. class Game_System
  48.   attr_accessor :formulas
  49.   attr_accessor :products
  50.   alias formulas_initialize initialize  
  51.   def initialize  
  52.     formulas_initialize
  53.     @formulas = []  
  54.     @products = []
  55. #############################################################################
  56. #  
  57. #===========================配方表===========================================   
  58. #
  59. #  配方格式
  60. #
  61. #  @formulas[i] = [[材料种类,材料编号,数量],[材料种类,材料编号,数量]……]                  
  62. #  @products[i] = [[成品种类,成品编号,数量],[成品种类,成品编号,数量]……]
  63. #   
  64. #  种类:物品 0 武器 1 防具 2
  65. #
  66. #  1.如果有两个配方材料相同,理论上会按编号较小的处理
  67. #  2.配方材料的顺序与合成是无关的(当然如果你想改成有关肯定也不会太麻烦)
  68. #  3.允许某个材料拆成多件成品(可能就不叫物品合成,应该叫物品分解了)
  69. #  4.暂时不支持多步合并为一步的合成  
  70. #       例如 A + B = C,C + D = E,如果不存在A + B + D = E的配方
  71. #       A + B + D无法合成 E  
  72. #
  73. #############################################################################
  74.     @formulas[0] = []
  75.     @products[0] = []
  76.     # 样例1: 回复剂x3 = 超回复剂x1
  77.     @formulas[1] = [[1,1,1],[0,200,1]]         
  78.     @products[1] = [[1,38,1]]
  79.     @formulas[2] = [[2,1,1],[0,201,1]]
  80.     @products[2] = [[2,5,1]]
  81.     @formulas[3] = [[0,181,2],[0,183,2]]
  82.     @products[3] = [[0,202,1]]
  83.  
  84.     @formulas[4] = [[0,5,3]]
  85.     @products[4] = [[0,6,1]]
  86.     # 样例2: 完全恢复剂x1 + 超级香水x1 = 圣灵药x1
  87.     @formulas[5] = [[0,3,1],[0,6,1]]
  88.     @products[5] = [[0,7,1]]
  89.     # 样例3: 完全恢复剂x1 + 超级香水x1 = 完全圣灵药x1
  90.     # 被样例2 被覆盖
  91.     @formulas[6] = [[0,3,1],[0,6,1]]
  92.     @products[6] = [[0,8,1]]
  93.     # 圣灵药x1 = 完全恢复剂x1 + 超级香水x1 (Item_Decompose...)
  94.     @formulas[7] = [[0,7,1]]
  95.     @products[7] = [[0,3,1],[0,6,1]]
  96.     # 样例5: 铜剑x1 + 回复剂x1 + 铜铠x1 = 密斯利尔剑x1
  97.     @formulas[8] = [[1,1,1],[0,1,1],[2,1,1]]  
  98.     @products[8] = [[1,4,1]]
  99.   end  
  100.  
  101.   #-------------------------------------------------------------------------
  102.   # ● 判断物品是否是材料。#X☆R
  103.   #    kind :种类(物品 0 武器 1 防具 2) 。
  104.   #    id   :物品ID。
  105.   #-------------------------------------------------------------------------
  106.   def is_material?(kind, id)
  107.     @formulas.each do |a|
  108.       b = a.select{|i| i[0] == kind && i[1] == id}
  109.       return true unless b.empty?
  110.     end
  111.     return false
  112.   end
  113.   #-------------------------------------------------------------------------
  114.  
  115. end
  116.  
  117. class Game_Temp  
  118.   attr_accessor :forge
  119.   alias forge_item_initialize initialize  
  120.   def initialize  
  121.     forge_item_initialize
  122.     # 定义合成窗口中的物品储存区
  123.     [url=home.php?mod=space&uid=14254]@Forge[/url] = []  
  124.   end
  125. end
  126.  
  127. #==============================================================================
  128. # ■ Window_ForgeCommand
  129. #------------------------------------------------------------------------------
  130. #  合成画面、选择要做的事的窗口
  131. #==============================================================================
  132.  
  133. class Window_ComposeCommand < Window_Selectable
  134.   #--------------------------------------------------------------------------
  135.   # ● 初始化对像
  136.   #--------------------------------------------------------------------------
  137.   def initialize
  138.     super(0, 64, 640, 64)
  139.     self.contents = Bitmap.new(width - 32, height - 32)
  140.     @item_max = 4
  141.     @column_max = 4
  142.     @commands = ["选择材料", "加工", "放弃加工", "离开"]
  143.     refresh
  144.     self.index = 0
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ● 刷新
  148.   #--------------------------------------------------------------------------
  149.   def refresh
  150.     self.contents.clear
  151.     for i in 0...@item_max
  152.       draw_item(i)
  153.     end
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 描绘项目
  157.   #     index : 项目编号
  158.   #--------------------------------------------------------------------------
  159.   def draw_item(index)
  160.     x = 4 + index * 160
  161.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  162.   end
  163. end
  164.  
  165. #==============================================================================
  166. # ■ Window_ForgeLeft
  167. #------------------------------------------------------------------------------
  168. #  合成画面中显示拥有的物品的窗口
  169. #==============================================================================
  170.  
  171. class Window_ComposeLeft < Window_Selectable
  172.   #--------------------------------------------------------------------------
  173.   # ● 初始化对像
  174.   #--------------------------------------------------------------------------
  175.   def initialize
  176.     super(0, 128, 320, 352)
  177.     @column_max = 1
  178.     refresh
  179.     self.index = 0
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● 获取物品
  183.   #--------------------------------------------------------------------------
  184.   def item
  185.     return @data[self.index]
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● 刷新
  189.   #--------------------------------------------------------------------------
  190.   def refresh
  191.     if self.contents != nil
  192.       self.contents.dispose
  193.       self.contents = nil
  194.     end
  195.     self.update_cursor_rect
  196.     @data = []
  197.     for i in 1...$data_items.size
  198.       if $game_party.item_number(i) > 0
  199.         @data.push($data_items[i]) if $game_system.is_material?(0, i) #X☆R
  200.       end
  201.     end
  202.     for i in 1...$data_weapons.size
  203.       if $game_party.weapon_number(i) > 0
  204.         @data.push($data_weapons[i]) if $game_system.is_material?(1, i) #X☆R
  205.       end
  206.     end
  207.     for i in 1...$data_armors.size
  208.       if $game_party.armor_number(i) > 0
  209.         @data.push($data_armors[i]) if $game_system.is_material?(2, i) #X☆R
  210.       end
  211.     end
  212.     # 如果项目数不是 0 就生成位图、描绘全部项目
  213.     @item_max = @data.size
  214.     if @item_max > 0
  215.       self.contents = Bitmap.new(width - 32, row_max * 32)
  216.       for i in 0...@item_max
  217.         draw_item(i)
  218.       end
  219.     end
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 描绘项目
  223.   #     index : 项目标号
  224.   #--------------------------------------------------------------------------
  225.   def draw_item(index)
  226.     item = @data[index]
  227.     case item
  228.     when RPG::Item
  229.       number = $game_party.item_number(item.id)
  230.     when RPG::Weapon
  231.       number = $game_party.weapon_number(item.id)
  232.     when RPG::Armor
  233.       number = $game_party.armor_number(item.id)
  234.     end
  235.     self.contents.font.color = normal_color
  236.     x = 4
  237.     y = index * 32
  238.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  239.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  240.     bitmap = RPG::Cache.icon(item.icon_name)
  241.     opacity = self.contents.font.color == normal_color ? 255 : 128
  242.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  243.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  244.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  245.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # ● 刷新帮助文本
  249.   #--------------------------------------------------------------------------
  250.   def update_help
  251.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  252.   end
  253. end
  254.  
  255. #==============================================================================
  256. # ■ Window_ForgeRight
  257. #------------------------------------------------------------------------------
  258. #  合成画面中的合成区窗口
  259. #==============================================================================
  260.  
  261. class Window_ComposeRight < Window_Selectable
  262.   attr_accessor :forge_item
  263.   #--------------------------------------------------------------------------
  264.   # ● 初始化对像
  265.   #--------------------------------------------------------------------------
  266.   def initialize(forge_item)
  267.     super(320, 128, 320, 352)
  268.     @column_max = 1
  269.     @forge_item = []
  270.     refresh
  271.     self.index = 0
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   # ● 获取物品
  275.   #--------------------------------------------------------------------------
  276.   def item
  277.     return @data[self.index]
  278.   end
  279.   #--------------------------------------------------------------------------  
  280.   # ● 获取物品  
  281.   #--------------------------------------------------------------------------  
  282.   def item_number  
  283.     return @data_number[self.index]  
  284.   end  
  285.   #--------------------------------------------------------------------------
  286.   # ● 刷新
  287.   #--------------------------------------------------------------------------
  288.   def refresh
  289.     if self.contents != nil
  290.       self.contents.dispose
  291.       self.contents = nil
  292.     end
  293.     @data = []
  294.     @data_number = []  
  295.     @forge_item = $game_temp.forge
  296.     for item_forge in @forge_item
  297.       case item_forge[0]
  298.       when 0
  299.         item = $data_items[item_forge[1]]
  300.       when 1
  301.         item = $data_weapons[item_forge[1]]
  302.       when 2
  303.         item = $data_armors[item_forge[1]]
  304.       end
  305.       if (item != nil) and (item_forge[2] != 0)  
  306.         @data.push(item)  
  307.         @data_number.push(item_forge[2])  
  308.       else  
  309.         @data.delete(item)  
  310.       end  
  311.     end
  312.     # 如果项目数不是 0 就生成位图、描绘全部项目
  313.     @item_max = @data.size
  314.     if @item_max > 0
  315.       self.contents = Bitmap.new(width - 32, row_max * 32)
  316.       for i in 0...@item_max
  317.         draw_item(i)
  318.       end
  319.     end
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ● 描绘项目
  323.   #     index : 项目标号
  324.   #--------------------------------------------------------------------------
  325.   def draw_item(index)
  326.     item = @data[index]
  327.     case item
  328.     when RPG::Item
  329.       number = $game_temp.forge[index][2]
  330.     when RPG::Weapon
  331.       number = $game_temp.forge[index][2]
  332.     when RPG::Armor
  333.       number = $game_temp.forge[index][2]
  334.     end
  335.     self.contents.font.color = normal_color
  336.     x = 4
  337.     y = index * 32
  338.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  339.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  340.     bitmap = RPG::Cache.icon(item.icon_name)
  341.     opacity = self.contents.font.color == normal_color ? 255 : 128
  342.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  343.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  344.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  345.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● 刷新帮助文本
  349.   #--------------------------------------------------------------------------
  350.   def update_help
  351.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  352.   end
  353. end
  354.  
  355. #==============================================================================
  356. # ■ Scene_Compose
  357. #------------------------------------------------------------------------------
  358. #  处理物品合成画面的类
  359. #==============================================================================
  360.  
  361. class Scene_Compose
  362. #--------------------------------------------------------------------------
  363. # ● 初始化
  364. #--------------------------------------------------------------------------
  365. def initialize
  366.    # 生成帮助窗口
  367.    @help_window = Window_Help.new
  368.    # 生成命令窗口
  369.    @command_window = Window_ComposeCommand.new
  370.    @command_window.active = false
  371.    # 生成左方窗口
  372.    @item_window = Window_ComposeLeft.new
  373.    @item_window.active = true
  374.    @item_window.help_window = @help_window
  375.    # 生成右方窗口
  376.    @forge_window = Window_ComposeRight.new([])
  377.    @forge_window.active = false
  378.    @forge_window.help_window = @help_window
  379.    # 初始化配方与合成区
  380.    @formulas = $game_system.formulas
  381.    @products = $game_system.products
  382.    @Forge = []
  383.    @products_temp = []      
  384. end
  385.   #--------------------------------------------------------------------------
  386.   # ● 主处理
  387.   #--------------------------------------------------------------------------
  388. def main
  389.    # 执行过渡
  390.    Graphics.transition
  391.    # 主循环
  392.    loop do
  393.      # 刷新游戏画面
  394.      Graphics.update
  395.      # 刷新输入情报
  396.      Input.update
  397.      # 刷新画面
  398.      update
  399.      # 如果画面被切换的话就中断循环
  400.      if $scene != self
  401.        break
  402.      end
  403.    end
  404.    # 准备过渡
  405.    Graphics.freeze
  406.    # 释放窗口
  407.    @help_window.dispose
  408.    @command_window.dispose
  409.    @item_window.dispose
  410.    @forge_window.dispose
  411. end
  412.   #--------------------------------------------------------------------------
  413.   # ● 刷新画面
  414.   #--------------------------------------------------------------------------  
  415. def update
  416.    @help_window.update
  417.    @command_window.update
  418.    @item_window.update
  419.    @forge_window.update
  420.    if @command_window.active
  421.      update_command
  422.      return
  423.    end
  424.    if @item_window.active
  425.      update_item
  426.      return
  427.    end
  428.    if @forge_window.active
  429.      update_forge
  430.      return
  431.    end
  432.     return
  433. end
  434.   #--------------------------------------------------------------------------
  435.   # ● 刷新画面(指令窗口激活的情况下)
  436.   #--------------------------------------------------------------------------
  437.   def update_command
  438.     # 按下 B 键的情况下
  439.     if Input.trigger?(Input::B)
  440.       # 演奏取消 SE
  441.       $game_system.se_play($data_system.cancel_se)
  442.       abort
  443.       # 切换到地图画面
  444.       $scene = Scene_Map.new
  445.       return
  446.     end
  447.      # 按下 C 键的情况下
  448.     if Input.trigger?(Input::C)
  449.       # 命令窗口光标位置分支
  450.       case @command_window.index
  451.       when 0  # 更改材料
  452.         # 演奏确定 SE
  453.         $game_system.se_play($data_system.decision_se)
  454.         # 窗口状态转向物品窗口
  455.         @command_window.active = false
  456.         @item_window.active = true
  457.         @forge_window.active = false
  458.       when 1  # 合成
  459.         # 演奏确定 SE
  460.         $game_system.se_play($data_system.decision_se)
  461.         # 执行合成命令
  462.         if $game_temp.forge != []
  463.           compose
  464.         end
  465.       when 2  # 放弃合成
  466.         # 演奏确定 SE
  467.         $game_system.se_play($data_system.decision_se)
  468.         # 放弃合成
  469.         abort
  470.       when 3  # 离开
  471.         # 演奏确定 SE
  472.         $game_system.se_play($data_system.decision_se)
  473.         # 放弃合成
  474.         abort
  475.         # 切换到地图画面
  476.         $scene = Scene_Map.new
  477.       end
  478.       return
  479.     end
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # ● 刷新画面(物品窗口激活的情况下)
  483.   #--------------------------------------------------------------------------
  484.   def update_item
  485.      # 按下 B 键的情况下
  486.     if Input.trigger?(Input::B)
  487.       # 演奏取消 SE
  488.       $game_system.se_play($data_system.cancel_se)
  489.       # 切换到指令窗口
  490.       @item_window.active = false
  491.       @command_window.active = true
  492.       @help_window.set_text("")
  493.       return
  494.     end
  495.      # 按下 C 键的情况
  496.     if Input.trigger?(Input::C)
  497.       # 演奏确定 SE
  498.       $game_system.se_play($data_system.decision_se)
  499.       # 获取物品
  500.       @item = @item_window.item
  501.       # 获取物品的所持数
  502.       case @item
  503.       when RPG::Item
  504.         number = $game_party.item_number(@item.id)
  505.         typetemp = 0
  506.       when RPG::Weapon
  507.         number = $game_party.weapon_number(@item.id)
  508.         typetemp = 1
  509.       when RPG::Armor
  510.         number = $game_party.armor_number(@item.id)
  511.         typetemp = 2
  512.       end
  513.       if number != nil
  514.         # 更改合成窗口的物品
  515.         case @item
  516.         when RPG::Item
  517.           $game_party.lose_item(@item.id, 1)
  518.         when RPG::Weapon
  519.           $game_party.lose_weapon(@item.id, 1)
  520.         when RPG::Armor
  521.           $game_party.lose_armor(@item.id, 1)
  522.         end
  523.         forge_change(typetemp, @item.id, 1)
  524.         # 刷新各窗口
  525.         @item_window.update
  526.         @help_window.update
  527.         @forge_window.update
  528.         @item_window.refresh
  529.         @forge_window.refresh
  530.       end
  531.     end
  532.      # 按下 右方向键 的情况
  533.     if Input.trigger?(Input::RIGHT)
  534.       # 切换到合成窗口
  535.       @item_window.active = false
  536.       @forge_window.active = true
  537.     end
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # ● 刷新画面(合成窗口激活的情况下)
  541.   #--------------------------------------------------------------------------
  542.   def update_forge
  543.      # 按下 B 键的情况下
  544.     if Input.trigger?(Input::B)
  545.       # 演奏取消 SE
  546.       $game_system.se_play($data_system.cancel_se)
  547.       # 切换到指令窗口
  548.       @forge_window.active = false
  549.       @command_window.active = true
  550.       @help_window.set_text("")
  551.       return
  552.     end
  553.      # 按下 C 键的情况
  554.     if Input.trigger?(Input::C)
  555.      # 演奏确定 SE
  556.      $game_system.se_play($data_system.decision_se)
  557.      # 获取物品
  558.       @item = @forge_window.item
  559.       # 获取物品的所持数
  560.       case @item
  561.       when RPG::Item
  562.         number = @forge_window.item_number
  563.         typetemp = 0
  564.       when RPG::Weapon
  565.         number = @forge_window.item_number
  566.         typetemp = 1
  567.       when RPG::Armor
  568.         number = @forge_window.item_number
  569.         typetemp = 2
  570.       end
  571.      if number != nil
  572.        # 更改合成窗口的物品
  573.        case @item
  574.        when RPG::Item
  575.          $game_party.gain_item(@item.id, 1)
  576.        when RPG::Weapon
  577.          $game_party.gain_weapon(@item.id, 1)
  578.        when RPG::Armor
  579.          $game_party.gain_armor(@item.id, 1)
  580.        end
  581.        #p number
  582.        forge_change(typetemp, @item.id, -1)
  583.        # 刷新各窗口
  584.        @item_window.refresh
  585.        @forge_window.refresh
  586.        @help_window.update
  587.        @item_window.update
  588.        @forge_window.update
  589.       end
  590.     end
  591.        # 按下 左方向键 的情况下
  592.     if Input.trigger?(Input::LEFT)
  593.       # 切换到合成窗口
  594.       @forge_window.active = false
  595.       @item_window.active = true
  596.     end
  597.   end
  598.   #--------------------------------------------------------------------------
  599.   # ● 更改合成窗口物品
  600.   #--------------------------------------------------------------------------
  601.   def forge_change(type,id,number)  
  602.      quantity = number  
  603.      for item in $game_temp.forge
  604.        if (item[0]==type) and (item[1]==id)  
  605.          item[2] = [item[2] += quantity,99].min  
  606.          if item[2] == 0  
  607.            $game_temp.forge.delete(item)  
  608.         end
  609.          return  
  610.        end  
  611.      end  
  612.      $game_temp.forge.push([type,id,number])  
  613.   end  
  614.   #--------------------------------------------------------------------------
  615.   # ● 放弃合成
  616.   #--------------------------------------------------------------------------  
  617.   def abort
  618.     # 将合成窗口中的物品转移至物品窗口中
  619.     for item in $game_temp.forge
  620.       # 判断物品类型并归还
  621.       case item[0]
  622.       when 0
  623.         $game_party.gain_item(item[1], item[2])
  624.       when 1
  625.         $game_party.gain_weapon(item[1], item[2])
  626.       when 2
  627.         $game_party.gain_armor(item[1], item[2])
  628.       end
  629.     end
  630.     $game_temp.forge = []
  631.     # 刷新各窗口
  632.     @item_window.refresh
  633.     @forge_window.refresh
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # ● 检测是否有符合的配方
  637.   #--------------------------------------------------------------------------
  638. def match
  639.    match_one = false
  640.    match_this = false
  641.     # 检测每一个配方
  642.    for i in [email]0...@formulas.size[/email]
  643.      # 将合成窗口中的物品复制到合成缓存区
  644.      # 注意: 直接使用"="将传引用 导致检测配方是否匹配时合成窗口中物品被删除
  645.      @forge = $game_temp.forge.dup
  646.      # 检测这个配方中每一项材料
  647.      for ingredient in @formulas[i]
  648.        match_this = true
  649.        # 合成区中没有此项材料的情况
  650.        unless @forge.include?(ingredient)
  651.          match_this = false
  652.          break
  653.        end
  654.        # 从合成区中暂时删除这项材料
  655.        @forge.delete(ingredient)
  656.      end
  657.      if match_this == false
  658.        next
  659.      end
  660.      # 检测合成区中是否还有配方外的材料剩余
  661.      unless @forge == []
  662.        match_this = false
  663.      end
  664.      # 满足这一个配方的情况
  665.      if match_this == true
  666.        match_one = true
  667.        # 获取配方的成品
  668.        @products_temp = @products[i]
  669.        break
  670.      end
  671.    end
  672.    return match_one
  673. end
  674.   #--------------------------------------------------------------------------
  675.   # ● 合成
  676.   #--------------------------------------------------------------------------
  677. def compose
  678.    #判断合成消耗物品是否携带
  679.    if $game_party.item_number(10) >= 1
  680.      #合成消耗物品减少
  681.      $game_party.gain_item(10,-1)
  682.    # 如果有符合的配方
  683.    if match
  684.      # 将合成窗口中的材料改变为成品
  685.      $game_temp.forge = []
  686.      for i in [email]0...@products_temp.size[/email]
  687.       forge_change(@products_temp[i][0], @products_temp[i][1], @products_temp[i][2])
  688.     end
  689.      if $SE_Compose_Successful != ""
  690.        Audio.se_play($SE_Compose_Successful)
  691.      end
  692.    # 合成失败的情况
  693.    else  
  694.      if $SE_Compose_Failed != ""
  695.        Audio.se_play($SE_Compose_Failed)
  696.      end
  697.      $game_party.gain_item(36,1)
  698.      if $Ingredient_Lost_When_Fail
  699.        $game_temp.forge = []
  700.      end
  701.    end
  702.    end
  703.     # 刷新各窗口
  704.    @item_window.refresh
  705.    @forge_window.refresh
  706. end
  707. end

Lv2.观梦者

故九江太守

梦石
0
星屑
559
在线时间
2160 小时
注册时间
2012-12-5
帖子
4463
2
发表于 2014-12-4 12:38:31 | 只看该作者
本帖最后由 你最珍贵 于 2014-12-4 13:12 编辑
  1.     if @forge_item == nil
  2.       @forge_item = []
  3.     end
复制代码
295行下面加上这段

点评

谢谢,在每个出错的FOR前面都加入这样的句子就没问题了。@forge_item改成IN后面的单词。  发表于 2014-12-4 13:35
编辑了  发表于 2014-12-4 13:12
提示是说each和FOR什么什么  发表于 2014-12-4 13:04
你误会了,是for item_forge in @forge_item这句报错  发表于 2014-12-4 12:57

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 12:46

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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