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

Project1

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

[已经解决] ZeroDivisionError

[复制链接]

Lv1.梦旅人

梦石
0
星屑
138
在线时间
304 小时
注册时间
2014-4-11
帖子
419
跳转到指定楼层
1
发表于 2014-9-9 14:42:50 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
我用了物品制造这个脚本
  1. #encoding:utf-8
  2. #==============================================================================
  3. # 本腳本來自www.66RPG.com,使用和轉載請保留此信息
  4. #==============================================================================
  5. #==============================================================================
  6. #
  7. #每添加一个制造的类型,最上面的类别菜单就会多一项。
  8. #
  9. #添加类型的方法是:
  10. #$game_party.add_cook_type(类别名称,类别介绍, 类别状态-默认false)
  11. #
  12. #举例:
  13. #$game_party.add_cook_type("制药","调配药品", true)
  14. #
  15. #添加配方的方法:
  16. #$game_party.add_cookbook(配方名称, 配方介绍, 配方类别名称,材料的二维数组,产出物的二维数组,配方状态)
  17. #
  18. #举例:
  19. #$game_party.add_cookbook("初级补血药水", "制作初级补血药水", "制药",[[18,2]],[[1,1]],true)
  20. #
  21. #调用窗口的方法:SceneManager.call(Scene_Cook)
  22. #
  23. #
  24. #==============================================================================

  25. #==============================================================================
  26. # ■ Cookbook_Type
  27. #------------------------------------------------------------------------------
  28. #  食谱类型类。
  29. #==============================================================================

  30. class Cookbook_Type
  31.   attr_reader :index
  32.   attr_reader :name
  33.   attr_reader :description
  34.   attr_reader :enabled
  35.   #--------------------------------------------------------------------------
  36.   # ● 初始化对象
  37.   #--------------------------------------------------------------------------
  38.   def initialize(index, name, description, enabled = false)
  39.     @index = index
  40.     @name = name
  41.     @description = description
  42.     @enabled = enabled
  43.   end
  44.   
  45.   def enable(en)
  46.     @enabled = en
  47.   end
  48. end

  49. #==============================================================================
  50. # ■ Cookbook
  51. #------------------------------------------------------------------------------
  52. #  食谱类。本类在 Game_Task 类的内部使用。
  53. #   食谱属性:食谱序号,食谱名称,食谱类型,食谱介绍,原料,成品
  54. #==============================================================================

  55. class Cookbook
  56.   attr_reader :index
  57.   attr_reader :name
  58.   attr_reader :description
  59.   attr_reader :type
  60.   attr_reader :input
  61.   attr_reader :output
  62.   attr_reader :enabled
  63.   #--------------------------------------------------------------------------
  64.   # ● 初始化对象
  65.   #--------------------------------------------------------------------------
  66.   def initialize(index, name, description, type, input, output, enabled = true)
  67.     @index = index
  68.     @name = name
  69.     @description = description
  70.     @type = type
  71.     @input = input
  72.     @output = output
  73.     @enabled = enabled
  74.   end
  75.   
  76.   def enable(en)
  77.     @enabled = en
  78.   end
  79.   
  80.   #--------------------------------------------------------------------------
  81.   # ● 查询列表中的物品
  82.   #--------------------------------------------------------------------------
  83.   def in_list?(item, list)
  84.     list.each do |arr|
  85.       return true if arr[0] == item.id
  86.     end
  87.     return false
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ● 查询是否是材料列表中的物品
  91.   #--------------------------------------------------------------------------
  92.   def resource?(item)
  93.     in_list?(item, @input)
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● 查询是否是产出列表中的物品
  97.   #--------------------------------------------------------------------------
  98.   def output?(item)
  99.     in_list?(item, @output)
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ● 查询材料需求量
  103.   #--------------------------------------------------------------------------
  104.   def amount(item, i)
  105.     if i == 0
  106.       @input.each do |arr|
  107.         return arr[1] if arr[0] == item.id
  108.       end
  109.     else
  110.       @output.each do |arr|
  111.         return arr[1] if arr[0] == item.id
  112.       end
  113.     end
  114.     return 0
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 查询材料是否足够
  118.   #--------------------------------------------------------------------------
  119.   def enough?
  120.     input.each do |arr|
  121.       return false if $data_items[arr[0]] && arr[1] > $game_party.item_number($data_items[arr[0]])
  122.     end
  123.     return true
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 查询某件材料是否足够
  127.   #--------------------------------------------------------------------------
  128.   def item_enough?(item)
  129.     input.each do |arr|
  130.       return false if arr[0] == item.id && arr[1] > $game_party.item_number(item)
  131.     end
  132.     return true
  133.   end
  134. end

  135. #==============================================================================
  136. # ■ Game_Party
  137. #==============================================================================

  138. class Game_Party < Game_Unit
  139.   #--------------------------------------------------------------------------
  140.   # ● 初始化对象
  141.   #--------------------------------------------------------------------------
  142.   alias old_init initialize
  143.   def initialize
  144.     old_init
  145.     @cook_types = []
  146.     @cookbooks = []
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 添加新的制造类型
  150.   #--------------------------------------------------------------------------
  151.   def add_cook_type(n, d, en)
  152.     @cook_types.push(Cookbook_Type.new(@cook_types.size, n, d, en)) if !have_cook_type?(n)
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 添加新的食谱
  156.   #--------------------------------------------------------------------------
  157.   def add_cookbook(n, d, type, input, output, en)
  158.     if !have_cookbook?(n) && have_cook_type?(type)
  159.       @cookbooks.push(Cookbook.new(@cookbooks.size, n, d, type, input, output, en))
  160.     end
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● 判断名称为n的制造类型是否存在
  164.   #--------------------------------------------------------------------------
  165.   def have_cook_type?(n)
  166.     @cook_types.each do |x|
  167.       return true if x.name == n
  168.     end
  169.     return false
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 判断名称为n的食谱是否存在
  173.   #--------------------------------------------------------------------------
  174.   def have_cookbook?(n)
  175.     @cookbooks.each do |x|
  176.       return true if x.name == n
  177.     end
  178.     return false
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ● 返回制造类型列表
  182.   #--------------------------------------------------------------------------
  183.   def cook_types
  184.     return @cook_types
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 返回食谱列表
  188.   #--------------------------------------------------------------------------
  189.   def cookbooks(type = nil)
  190.     return @cookbooks if type == nil
  191.     arr = []
  192.     @cookbooks.each do |x|
  193.       arr.push(x) if x.type == type
  194.     end
  195.     return arr
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # ● 更改序号为i的制造类型的使用状态
  199.   #--------------------------------------------------------------------------
  200.   def set_cook_type(i, en)
  201.     @cook_types[i].enable(en)
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ● 更改序号为i的食谱的使用状态
  205.   #--------------------------------------------------------------------------
  206.   def set_cookbook(i, en)
  207.     @cookbooks[i].enable(en)
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 返回制造类型数目
  211.   #--------------------------------------------------------------------------
  212.   def cook_types_size
  213.     return @cook_types.size
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● 查询名称为n的制造类型的描述
  217.   #--------------------------------------------------------------------------
  218.   def cook_type_description(n)
  219.     @cook_types.each do |x|
  220.       return x.description if x.name == n
  221.     end
  222.     return ""
  223.   end
  224. end

  225. #==============================================================================
  226. # ■ Scene_Cook
  227. #------------------------------------------------------------------------------
  228. #  制造画面
  229. #==============================================================================

  230. class Scene_Cook < Scene_ItemBase
  231.   #--------------------------------------------------------------------------
  232.   # ● 开始处理
  233.   #--------------------------------------------------------------------------
  234.   def start
  235.     super
  236.     create_category_window
  237.     create_cookbook_window
  238.     create_description_window
  239.     create_needs_window
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ● 生成分类窗口
  243.   #--------------------------------------------------------------------------
  244.   def create_category_window
  245.     @category_window = Window_CookCategory.new
  246.     @category_window.viewport = @viewport
  247.     @category_window.y = 0
  248.     @category_window.set_handler(:ok,     method(:on_category_ok))
  249.     @category_window.set_handler(:cancel, method(:return_scene))
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ● 生成食谱窗口
  253.   #--------------------------------------------------------------------------
  254.   def create_cookbook_window
  255.     wy = @category_window.height
  256.     wh = Graphics.height - wy
  257.     @item_window = Window_CookList.new(0, wy, Graphics.width*0.5 , wh)
  258.     @item_window.viewport = @viewport
  259.     @item_window.set_handler(:ok,     method(:on_item_ok))
  260.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  261.     @category_window.item_window = @item_window
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # ● 生成描述窗口
  265.   #--------------------------------------------------------------------------
  266.   def create_description_window
  267.     wy = @category_window.height
  268.     @help_window = Window_Description.new(Graphics.width*0.5, wy)
  269.     @help_window.viewport = @viewport
  270.     @item_window.help_window = @help_window
  271.     @category_window.help_window = @help_window
  272.   end
  273.     #--------------------------------------------------------------------------
  274.   # ● 生成材料窗口
  275.   #--------------------------------------------------------------------------
  276.   def create_needs_window
  277.     wy = @category_window.height + @help_window.height
  278.     wh = Graphics.height - wy
  279.     @needs_window = Window_NeedsList.new(Graphics.width*0.5, wy, Graphics.width*0.5 , wh)
  280.     #@item_window.viewport = @viewport
  281.     @item_window.needs_window = @needs_window
  282.    
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 分类“确定”
  286.   #--------------------------------------------------------------------------
  287.   def on_category_ok
  288.     @item_window.activate
  289.     @item_window.select_last
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # ● 食谱“确定”
  293.   #--------------------------------------------------------------------------
  294.   def on_item_ok
  295.     #$game_party.last_item.object = item
  296.     cook
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ● 食谱“取消”
  300.   #--------------------------------------------------------------------------
  301.   def on_item_cancel
  302.     @item_window.unselect
  303.     @category_window.activate
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● 制造
  307.   #--------------------------------------------------------------------------
  308.   def cook
  309.     if item.enough?
  310.       play_se_for_item
  311.       use_item
  312.       @needs_window.refresh
  313.       @item_window.refresh
  314.       activate_item_window
  315.     end
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # ● 播放制作声效
  319.   #--------------------------------------------------------------------------
  320.   def play_se_for_item
  321.     Sound.play_recovery
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # ● 使用食谱
  325.   #--------------------------------------------------------------------------
  326.   def use_item
  327.     #super
  328.     #@item_window.redraw_current_item
  329.     $data_items.each do |it|
  330.       if it && !it.name.empty?
  331.         $game_party.gain_item(it,-item.amount(it,0)) if item.resource?(it)
  332.         $game_party.gain_item(it,item.amount(it,1)) if item.output?(it)
  333.       end
  334.     end
  335.   end
  336. end


  337. #==============================================================================
  338. # ■ Window_CookCategory
  339. #------------------------------------------------------------------------------
  340. #  制造画面中,显示制造类型的窗口。
  341. #==============================================================================

  342. class Window_CookCategory < Window_HorzCommand
  343.   #--------------------------------------------------------------------------
  344.   # ● 定义实例变量
  345.   #--------------------------------------------------------------------------
  346.   attr_reader   :item_window
  347.   #--------------------------------------------------------------------------
  348.   # ● 初始化对象
  349.   #--------------------------------------------------------------------------
  350.   def initialize
  351.     super(0, 0)
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ● 获取窗口的宽度
  355.   #--------------------------------------------------------------------------
  356.   def window_width
  357.     Graphics.width
  358.   end
  359.   #--------------------------------------------------------------------------
  360.   # ● 获取列数
  361.   #--------------------------------------------------------------------------
  362.   def col_max
  363.     return $game_party.cook_types_size
  364.   end
  365.   #--------------------------------------------------------------------------
  366.   # ● 更新画面
  367.   #--------------------------------------------------------------------------
  368.   def update
  369.     super
  370.     #@item_window.category = current_symbol if @item_window
  371.     @item_window.category = current_data[:name] if @item_window
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # ● 生成制造列表
  375.   #--------------------------------------------------------------------------
  376.   def make_command_list
  377.     $game_party.cook_types.each do |t|
  378.       add_command(t.name, t.index, t.enabled)
  379.     end
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 设置制造列表窗口
  383.   #--------------------------------------------------------------------------
  384.   def item_window=(item_window)
  385.     @item_window = item_window
  386.     update
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # ● 更新帮助内容
  390.   #--------------------------------------------------------------------------
  391.   def update_help
  392.     @help_window.set_text($game_party.cook_type_description(current_data[:name]))
  393.   end
  394. end

  395. #==============================================================================
  396. # ■ Window_CookList
  397. #------------------------------------------------------------------------------
  398. #  任务画面中,显示已获得任务的窗口。
  399. #==============================================================================

  400. class Window_CookList < Window_Selectable
  401.   #--------------------------------------------------------------------------
  402.   # ● 定义实例变量
  403.   #--------------------------------------------------------------------------
  404.   attr_reader   :needs_window
  405.   #--------------------------------------------------------------------------
  406.   # ● 初始化对象
  407.   #--------------------------------------------------------------------------
  408.   def initialize(x, y, width, height)
  409.     super
  410.     @data = []
  411.     @category = $game_party.cook_types_size > 0 ? $game_party.cook_types[0].name : nil
  412.     refresh
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 设置分类
  416.   #--------------------------------------------------------------------------
  417.   def category=(category)
  418.     return if @category == category
  419.     @category = category
  420.     refresh
  421.     self.oy = 0
  422.   end
  423.   #--------------------------------------------------------------------------
  424.   # ● 设置材料窗口
  425.   #--------------------------------------------------------------------------
  426.   def needs_window=(needs_window)
  427.     @needs_window = needs_window
  428.     update
  429.   end
  430.   #--------------------------------------------------------------------------
  431.   # ● 获取列数
  432.   #--------------------------------------------------------------------------
  433.   def col_max
  434.     return 1
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # ● 获取项目数
  438.   #--------------------------------------------------------------------------
  439.   def item_max
  440.     @data ? @data.size : 1
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # ● 获取食谱
  444.   #--------------------------------------------------------------------------
  445.   def item
  446.     @data && index >= 0 ? @data[index] : nil
  447.   end
  448.   #--------------------------------------------------------------------------
  449.   # ● 获取选择食谱的有效状态
  450.   #--------------------------------------------------------------------------
  451.   def current_item_enabled?
  452.     enable?(@data[index])
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # ● 查询此食谱是否可用
  456.   #--------------------------------------------------------------------------
  457.   def enable?(item)
  458.     item.enabled && item.enough?
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ● 生成食谱列表
  462.   #--------------------------------------------------------------------------
  463.   def make_item_list
  464.     @data = $game_party.cookbooks(@category)
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # ● 返回上一个选择的位置
  468.   #--------------------------------------------------------------------------
  469.   def select_last
  470.     select(0)
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # ● 绘制项目
  474.   #--------------------------------------------------------------------------
  475.   def draw_item(index)
  476.     item = @data[index]
  477.     if item
  478.       rect = item_rect(index)
  479.       rect.width -= 4
  480.       draw_item_name(item, rect.x, rect.y, enable?(item))
  481.     end
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # ● 绘制名称
  485.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  486.   #--------------------------------------------------------------------------
  487.   def draw_item_name(item, x, y, enabled = true, width = 300)
  488.     return unless item
  489.     text = item.name
  490.     text += "[材料不足]" if !item.enough?
  491.     change_color(normal_color, enabled)
  492.     draw_text(x, y, width, line_height, text)
  493.   end
  494.   #--------------------------------------------------------------------------
  495.   # ● 更新帮助内容
  496.   #--------------------------------------------------------------------------
  497.   def update_help
  498.     @help_window.set_item(item)
  499.   end
  500.    #--------------------------------------------------------------------------
  501.   # ● 更新食谱清单
  502.   #--------------------------------------------------------------------------
  503.   def update_needslist
  504.     @needs_window.set_item(item)
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # ● 调用帮助窗口的更新方法
  508.   #--------------------------------------------------------------------------
  509.   def call_update_help
  510.     update_help if @help_window
  511.     update_needslist if @needs_window
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # ● 刷新
  515.   #--------------------------------------------------------------------------
  516.   def refresh
  517.     make_item_list
  518.     create_contents
  519.     draw_all_items
  520.   end
  521. end
  522. #==============================================================================
  523. # ■ Window_Description
  524. #------------------------------------------------------------------------------
  525. #  显示食谱的说明的窗口
  526. #==============================================================================

  527. class Window_Description < Window_Base
  528.   #--------------------------------------------------------------------------
  529.   # ● 初始化对象
  530.   #--------------------------------------------------------------------------
  531.   def initialize(x, y)
  532.     super(x, y, Graphics.width*0.5, fitting_height(4))
  533.   end
  534.   #--------------------------------------------------------------------------
  535.   # ● 设置内容
  536.   #--------------------------------------------------------------------------
  537.   def set_text(text)
  538.     if text != @text
  539.       @text = text
  540.       refresh
  541.     end
  542.   end
  543.   #--------------------------------------------------------------------------
  544.   # ● 清除
  545.   #--------------------------------------------------------------------------
  546.   def clear
  547.     set_text("")
  548.   end
  549.   #--------------------------------------------------------------------------
  550.   # ● 设置食谱的介绍
  551.   #--------------------------------------------------------------------------
  552.   def set_item(item)
  553.     set_text(item ? item.description : "")
  554.   end
  555.   #--------------------------------------------------------------------------
  556.   # ● 刷新
  557.   #--------------------------------------------------------------------------
  558.   def refresh
  559.     contents.clear
  560.     draw_text_ex(4, 0, @text)
  561.   end
  562. end

  563. #==============================================================================
  564. # ■ Window_NeedsList
  565. #------------------------------------------------------------------------------
  566. #  制造画面中,显示食谱所需材料的窗口。
  567. #==============================================================================

  568. class Window_NeedsList < Window_Selectable
  569.   #--------------------------------------------------------------------------
  570.   # ● 初始化对象
  571.   #--------------------------------------------------------------------------
  572.   def initialize(x, y, width, height)
  573.     super
  574.     @category = :item
  575.     @cookbook = nil
  576.     @data = []
  577.     refresh
  578.   end
  579.   #--------------------------------------------------------------------------
  580.   # ● 获取列数
  581.   #--------------------------------------------------------------------------
  582.   def col_max
  583.     return 1
  584.   end
  585.   #--------------------------------------------------------------------------
  586.   # ● 获取项目数
  587.   #--------------------------------------------------------------------------
  588.   def item_max
  589.     @data ? @data.size : 1
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # ● 获取物品
  593.   #--------------------------------------------------------------------------
  594.   def item
  595.     @data && index >= 0 ? @data[index] : nil
  596.   end
  597.   #--------------------------------------------------------------------------
  598.   # ● 查询列表中是否含有此物品
  599.   #--------------------------------------------------------------------------
  600.   def include?(item)
  601.     item.is_a?(RPG::Item) && !item.key_item?
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # ● 获取选择食谱的有效状态
  605.   #--------------------------------------------------------------------------
  606.   def current_item_enabled?
  607.     enable?(@data[index])
  608.   end
  609.   #--------------------------------------------------------------------------
  610.   # ● 查询此食谱是否可用
  611.   #--------------------------------------------------------------------------
  612.   def enable?(item)
  613.     $game_party.usable?(item) && @cookbook.item_enough?(item)
  614.   end
  615.   #--------------------------------------------------------------------------
  616.   # ● 生成物品列表
  617.   #--------------------------------------------------------------------------
  618.   def make_item_list
  619.     @data = []
  620.     return if @cookbook== nil
  621.     tmp1 = []
  622.     tmp2 = []
  623.     $data_items.each do |item|
  624.       tmp1.push([item, 0]) if item && !item.name.empty? && @cookbook.resource?(item)
  625.       tmp2.push([item, 1]) if item && !item.name.empty? && @cookbook.output?(item)
  626.     end
  627.     if tmp1.size > 0 && tmp2.size > 0
  628.       @data.push(["需要材料:",0])
  629.       @data += tmp1
  630.       @data.push(["可以获得:",1])
  631.       @data += tmp2
  632.     end
  633.   end
  634.   #--------------------------------------------------------------------------
  635.   # ● 返回上一个选择的位置
  636.   #--------------------------------------------------------------------------
  637.   def select_last
  638.     select(0)
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ● 绘制项目
  642.   #--------------------------------------------------------------------------
  643.   def draw_item(index)
  644.     item = @data[index]
  645.     if item
  646.       rect = item_rect(index)
  647.       rect.width -= 4
  648.       if item[0].is_a?(RPG::Item)
  649.         draw_item_name(item, rect.x, rect.y, enable?(item[0]))
  650.         draw_item_number(rect, item[0])
  651.       else
  652.         draw_input_output(item, rect.x, rect.y)
  653.       end
  654.     end
  655.   end
  656.   #--------------------------------------------------------------------------
  657.   # ● 绘制物品名称
  658.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  659.   #--------------------------------------------------------------------------
  660.   def draw_item_name(item, x, y, enabled = true, width = 172)
  661.     return unless item
  662.     text = item[0].name + "*" + String(@cookbook.amount(item[0], item[1]))
  663.     draw_icon(item[0].icon_index, x, y, enabled)
  664.     change_color(normal_color, enable?(item[0]))
  665.     draw_text(x + 24, y, width, line_height, text)
  666.   end
  667.   #--------------------------------------------------------------------------
  668.   # ● 绘制输入和产出
  669.   #--------------------------------------------------------------------------
  670.   def draw_input_output(item, x, y, enabled = false, width = 172)
  671.     return unless item
  672.     if item[1] == 0
  673.       text = "[需要]"
  674.     else
  675.       text = "[可以获得]"
  676.     end
  677.     change_color(normal_color, @cookbook.enough?)
  678.     draw_text(x , y, width, line_height, text)
  679.   end
  680.   #--------------------------------------------------------------------------
  681.   # ● 绘制物品个数
  682.   #--------------------------------------------------------------------------
  683.   def draw_item_number(rect, item)
  684.     draw_text(rect, sprintf("现有%2d", $game_party.item_number(item)), 2)
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # ● 刷新
  688.   #--------------------------------------------------------------------------
  689.   def refresh
  690.     make_item_list
  691.     create_contents
  692.     draw_all_items
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # ● 设置食谱的材料
  696.   #--------------------------------------------------------------------------
  697.   def set_item(item)
  698.     @cookbook = item
  699.     refresh
  700.   end
  701. end
  702. #==============================================================================
  703. # 本腳本來自www.66RPG.com,使用和轉載請保留此信息
  704. #==============================================================================
复制代码
在window menucommond中做了这样的修改
  1.   #--------------------------------------------------------------------------
  2.   # ● 向指令列表添加主要的指令
  3.   #--------------------------------------------------------------------------
  4.   def add_main_commands
  5.     add_command(Vocab::item,   :item,   main_commands_enabled)
  6.     add_command(Vocab::skill,  :skill,  main_commands_enabled)
  7.     add_command(Vocab::equip,  :equip,  main_commands_enabled)
  8.     add_command(Vocab::status, :status, main_commands_enabled)
  9.     add_command("制造",   :cook,   main_commands_enabled)
  10.   end
复制代码
在scene mune中做了如下修改
  1.   #--------------------------------------------------------------------------
  2.   # ● 生成指令窗口
  3.   #--------------------------------------------------------------------------
  4.   def create_command_window
  5.     @command_window = Window_MenuCommand.new
  6.     @command_window.set_handler(:item,      method(:command_item))
  7.     @command_window.set_handler(:skill,     method(:command_personal))
  8.     @command_window.set_handler(:equip,     method(:command_personal))
  9. #~     @command_window.set_handler(:status,    method(:command_personal))
  10.     @command_window.set_handler(:cook,      method(:command_cook))
  11. #~     @command_window.set_handler(:formation, method(:command_formation))
  12.     @command_window.set_handler(:save,      method(:command_save))
  13.     @command_window.set_handler(:game_end,  method(:command_game_end))
  14.     @command_window.set_handler(:cancel,    method(:return_scene))
  15.     @command_window.x = - 24 + @dx + 26
  16.     @command_window.y = 72
  17.     @command_window.opacity = 0

  18.   end
复制代码
然后报错ZeroDivisionError
当除数为 0 时抛出此异常。
报错的地方是window selectable50行
  1.   #--------------------------------------------------------------------------
  2.   # ● 获取项目的宽度
  3.   #--------------------------------------------------------------------------
  4.   def item_width
  5.     (width - standard_padding * 2 + spacing) / col_max - spacing
  6.   end
复制代码
这是肿么了
人生是一场漫长的自杀。

Lv3.寻梦者

闇吼者の災悪眷族
不気味存在締造者

梦石
0
星屑
1366
在线时间
2881 小时
注册时间
2014-7-29
帖子
6491
3
发表于 2014-9-9 14:53:42 | 只看该作者
本帖最后由 三途亚梦 于 2014-9-9 14:55 编辑

这个脚本虽然自由度高,用起来还比较方便,就是可惜有一些细节错误……另外不能好像还没法删除配方

要做到随着游戏进行逐渐增加合成列表,这个脚本就比较有优势。

点评

这个脚本还是很不错的  发表于 2014-9-9 15:13
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (版主)

无限の剣制

梦石
0
星屑
10073
在线时间
5020 小时
注册时间
2013-2-28
帖子
5030

开拓者贵宾

2
发表于 2014-9-9 14:46:09 | 只看该作者
本帖最后由 VIPArcher 于 2014-9-9 14:47 编辑

你没添加任何一种配方类型,就打开窗口。
这是这个脚本作者的没考虑周全的原因。
解决方法当然就是先添加配方类型后再打开窗口咯。

点评

感谢 可结贴  发表于 2014-9-9 14:47

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-20 11:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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