查看: 2562|回复: 6

[已经解决] 电话与任务脚本的兼容请教

[复制链接]
梦石
0
星屑
4017
在线时间
604 小时
注册时间
2017-4-21
回帖
177
发表于 2018-5-25 01:00:51 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 阮声悠悠 于 2018-5-25 12:32 编辑

如下。是论坛上一个很棒的任务系统,我对脚本做了一些更改,使它变成电话系统

我是个脚本渣渣,所以有两个问题想请教。

1. 两个系统不能同时使用,双击打开游戏就会报错
通话脚本35行发生了SystemStackError
stack level too deep
2. 电话脚本,如下图,当主角选择好要拨打的对象,会返回地图,并执行1号公共事件
那么,该怎么在1号公共事件判断,我选择的是哪个呢?

通话系统:


  1. #===============================================================================
  2. # ■ 队伍
  3. #===============================================================================
  4. class Game_Party
  5.   Tonghua = Struct.new(:id, :name, :info, :status)
  6.   alias org_init_tonghua initialize if !defined?(org_init_tonghua)
  7.   #--------------------------------------------------------------------------
  8.   # ● 重定义初始化
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     @tonghua = {}
  12.     org_init_tonghua
  13.   end
  14.   def no_tonghua?
  15.     return @tonghua == {}
  16.   end
  17.   def tonghuas
  18.     if no_tonghua?
  19.       m = Tonghua.new(0,"没有电话"," ",0)
  20.       return [m]
  21.     end
  22.     return @tonghua.values.sort_by {|m|m.id}
  23.   end
  24.   def get_tonghua(tonghua,info)
  25.     return if @tonghua.has_key?(tonghua)
  26.     id = tonghuas[-1].id + 1
  27.     @tonghua[tonghua] = Tonghua.new(id,tonghua,info,0)
  28.   end
  29.   def done_tonghua(tonghua)
  30.     @mission[tonghua].status = 1 if @tonghua[tonghua].status == 0
  31.   end
  32.   def delete_tonghua(tonghua)
  33.     @tonghua.delete(tonghua)
  34.   end
  35.   def fail_tonghua(tonghua)
  36.     @tonghua[tonghua].status = 2 if @tonghua[tonghua].status == 0
  37.   end
  38.   def resume_tonghua(tonghua)
  39.     @tonghua[tonghua].status = 0 if @tonghua[tonghua].status == 2
  40.   end
  41.   def done_all_tonghua
  42.     @tonghua.each{|k,m|m.status = 1}
  43.   end
  44.   def update_tonghua(tonghua,info)
  45.     @tonghua[tonghua].info = info
  46.   end
  47.   def add_tonghua_info(tonghua,info)
  48.     @tonghua[tonghua].info += "\n" + info
  49.   end
  50.   def delete_all_tonghua
  51.     @tonghua = {}
  52.   end
  53.   def resume_all_tonghua
  54.     @tonghua.each{|k,n|n.status = 0 if m.status == 2}
  55.   end
  56. end


  57. #===============================================================================
  58. # ■ 任务列表窗口
  59. #===============================================================================
  60. class Window_Tonghua < Window_Selectable
  61.   #--------------------------------------------------------------------------
  62.   # ● 初始化对象
  63.   #--------------------------------------------------------------------------
  64.   def initialize
  65.     super(220, 90, 200, 280)
  66.     self.index = 0
  67.     @tonghua = $game_party.tonghuas
  68.     @item_max = @tonghua.size
  69.     if self.contents != nil
  70.       self.contents.dispose
  71.       self.contents = nil
  72.     end
  73.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  74.     for i in 0...@tonghua.size
  75.       t = @tonghua[i].status != 0
  76.       self.contents.font.color = t ? disabled_color : normal_color
  77.       text = @tonghua[i].name
  78.       self.contents.draw_text(4, i * 32, 160, 32, text.to_s)
  79.       self.contents.font.color = system_color
  80.     end
  81.   end
  82. end
  83. #===============================================================================
  84. # ■ 任务界面
  85. #===============================================================================
  86. class Scene_Tonghua
  87.   #--------------------------------------------------------------------------
  88.   # ● 初始化
  89.   #--------------------------------------------------------------------------
  90.   def initialize
  91.     @last_scene = $scene
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 主处理
  95.   #--------------------------------------------------------------------------
  96.   def main
  97.     screen = Spriteset_Map.new
  98.     @tonghua = $game_party.tonghuas
  99.     @tonghua_window = Window_Tonghua.new
  100.     @tonghua_window.index = 0#@mission.size - 1
  101.     @index = @tonghua_window.index
  102.     Graphics.transition
  103.     loop do
  104.       Graphics.update
  105.       Input.update
  106.       update
  107.       if $scene != self
  108.         break
  109.       end
  110.     end
  111.     Graphics.freeze
  112.     @tonghua_window.dispose
  113.     screen.dispose
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 刷新画面
  117.   #--------------------------------------------------------------------------
  118.   def update
  119.     @tonghua_window.update
  120.     if @index != @tonghua_window.index
  121.       @index = @tonghua_window.index
  122.     end
  123.     return update_mission if @tonghua_window.active
  124.     update_info
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 刷新任务
  128.   #--------------------------------------------------------------------------
  129.   def update_mission
  130.     if Input.trigger?(Input::C)
  131.       $game_system.se_play($data_system.decision_se)
  132.       $game_temp.common_event_id = 1
  133.       $scene = Scene_Map.new
  134.     elsif Input.trigger?(Input::B)
  135.       $game_system.se_play($data_system.cancel_se)
  136.       $scene = Scene_Map.new#$scene = @last_scene
  137.       return
  138.     end
  139.   end
  140. end
复制代码



任务系统
  1. #==============================================================================#
  2. #                          便民任务界面 by EngShun                             #
  3. #    $scene = Scene_Mission.new 打开脚本                                                                        #
  4. #    由于此版本仅做出了一些小优化,                                            #
  5. #    因此设置方法请参考v0.7的范例                                              #
  6. #                                                                              #
  7. #    效果说明:                                                                #
  8. #    支持普通对话框效果                                                        #
  9. #    \a[号码]     :更改左右对齐方式(0,1,2)。                                 #
  10. #    \itm[物品id] :物品数量                                                    #
  11. #    \wpn[武器id] :武器数量                                                    #
  12. #    \amr[防具id] :防具数量                                                    #
  13. #    \eval{脚本}  :运行脚本                                                    #
  14. #    \1line{内容} :把多行的内容显示为一行                                      #
  15. #    \bold        :字体加粗,插入多一次关闭                                    #
  16. #    \italic      :字体打斜,插入多一次关闭                                    #
  17. #    \f[字体名称] :更改字体                                                    #
  18. #    \s[号码]     :更改字体大小                                                #
  19. #    \p[名称]     :插入图片                                                    #
  20. #    \icon[名称]  :插入图标                                                    #
  21. #                                                                              #
  22. #==============================================================================#

  23. #===============================================================================
  24. # ■ 队伍
  25. #===============================================================================
  26. class Game_Party
  27.   Mission = Struct.new(:id, :name, :info, :status)
  28.   alias org_init_mission initialize if !defined?(org_init_mission)
  29.   #--------------------------------------------------------------------------
  30.   # ● 重定义初始化
  31.   #--------------------------------------------------------------------------
  32.   def initialize
  33.     @mission = {}
  34.     org_init_mission
  35.   end
  36.   
  37.   def no_mission?
  38.     return @mission == {}
  39.   end
  40.   
  41.   def missions
  42.     if no_mission?
  43.       m = Mission.new(0,"没有任务"," ",0)
  44.       return [m]
  45.     end
  46.     return @mission.values.sort_by {|m|m.id}
  47.   end
  48.   
  49.   def get_mission(mission,info)
  50.     return if @mission.has_key?(mission)
  51.     id = missions[-1].id + 1
  52.     @mission[mission] = Mission.new(id,mission,info,0)
  53.   end

  54.   
  55.   def done_mission(mission)
  56.     @mission[mission].status = 1 if @mission[mission].status == 0
  57.   end

  58.   
  59.   def delete_mission(mission)
  60.     @mission.delete(mission)
  61.   end

  62.   
  63.   def fail_mission(mission)
  64.     @mission[mission].status = 2 if @mission[mission].status == 0
  65.   end

  66.   
  67.   def resume_mission(mission)
  68.     @mission[mission].status = 0 if @mission[mission].status == 2
  69.   end

  70.   
  71.   def done_all_mission
  72.     @mission.each{|k,m|m.status = 1}
  73.   end

  74.   
  75.   def update_mission(mission,info)
  76.     @mission[mission].info = info
  77.   end

  78.   
  79.   def add_mission_info(mission,info)
  80.     @mission[mission].info += "\n" + info
  81.   end

  82.   
  83.   def delete_all_mission
  84.     @mission = {}
  85.   end

  86.   
  87.   def resume_all_mission
  88.     @mission.each{|k,m|m.status = 0 if m.status == 2}
  89.   end

  90.   
  91. end

  92. #===============================================================================
  93. # ■ 任务列表窗口
  94. #===============================================================================
  95. class Window_Mission < Window_Selectable
  96.   #--------------------------------------------------------------------------
  97.   # ● 初始化对象
  98.   #--------------------------------------------------------------------------
  99.   def initialize
  100.     super(0, 64, 200, 416)
  101.     self.index = 0
  102.     @mission = $game_party.missions
  103.     @item_max = @mission.size
  104.     if self.contents != nil
  105.       self.contents.dispose
  106.       self.contents = nil
  107.     end
  108.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  109.     for i in 0...@mission.size
  110.       t = @mission[i].status != 0
  111.       self.contents.font.color = t ? disabled_color : normal_color
  112.       text = @mission[i].name
  113.       self.contents.draw_text(4, i * 32, 160, 32, text.to_s)
  114.       self.contents.font.color = system_color
  115.       self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "□",1) unless $game_party.no_mission?
  116.       if @mission[i].status == 1
  117.         self.contents.font.color = crisis_color
  118.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "√",1)
  119.       elsif @mission[i].status == 2
  120.         self.contents.font.color = knockout_color
  121.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "×",1)
  122.       end
  123.     end
  124.   end
  125. end

  126. #===============================================================================
  127. # ■ 任务详情窗口
  128. #===============================================================================
  129. class Window_MissionInfo < Window_Base
  130.   attr_accessor :wait
  131.   attr_accessor :scroll_up
  132.   #--------------------------------------------------------------------------
  133.   # ● 初始化对象
  134.   #--------------------------------------------------------------------------
  135.   def initialize
  136.     super(200,64,440,416)
  137.     self.contents =  Bitmap.new(408, 384)
  138.     @scroll_up = false
  139.     @wait = 90
  140.     @items = []
  141.     @progress = 0
  142.     @draw_y = 0
  143.     @align = 0
  144.     @cache = Bitmap.new(160,160)
  145.     @font = Font.new
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● 刷新画面
  149.   #--------------------------------------------------------------------------
  150.   def update
  151.     super
  152.     parse_items if @items.size > 0
  153.     return if self.contents.height <= 384
  154.     return @wait -= 1 if @wait > 0
  155.     self.oy += @scroll_up ? -1 : 1
  156.     self.oy = 0 if self.oy < 0
  157.     self.oy = oy_max if self.oy > oy_max
  158.     if self.oy <= 0
  159.       @scroll_up = false
  160.       @wait = 60
  161.     elsif self.oy >= oy_max
  162.       @scroll_up = true
  163.       @wait = 60
  164.     end
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ● 释放
  168.   #--------------------------------------------------------------------------
  169.   def dispose
  170.     super
  171.     @cache.dispose
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ● 滚动最大值
  175.   #--------------------------------------------------------------------------
  176.   def oy_max
  177.     return self.contents.height - 384
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 刷新
  181.   #--------------------------------------------------------------------------
  182.   def refresh(str)
  183.     str = str.clone
  184.     @scroll_up = false
  185.     @wait = 120
  186.     @draw_y = 0
  187.     @align = 0
  188.     @progress = 0
  189.     @lines = []
  190.     self.oy = 0
  191.     @cache.font = Font.new
  192.     @font = Font.new
  193.     self.contents.dispose
  194.     self.contents = Bitmap.new(408, 384)
  195.     parse_text(str)
  196.     12.times{parse_items}
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 描绘行
  200.   #--------------------------------------------------------------------------
  201.   def draw_line(width, height, items)
  202.     bitmap = Bitmap.new(width, height)
  203.     bitmap.font = @font
  204.     x = 0
  205.     for item in items
  206.       if item.is_a?(Color)
  207.         bitmap.font.color = item
  208.       elsif item.is_a?(Integer)
  209.         bitmap.font.size = item
  210.       elsif item.is_a?(Array)
  211.         bitmap.font.name = item[0] if item.size == 1
  212.       elsif item.is_a?(Bitmap)
  213.         bitmap.blt(x + 2, (height - item.height) / 2,
  214.                    item, Rect.new(0,0,item.width,item.height))
  215.         x += item.width + 4
  216.       elsif item == :bold
  217.         bitmap.font.italic = !bitmap.font.bold
  218.       elsif item == :italic
  219.         bitmap.font.italic = !bitmap.font.italic
  220.       else
  221.         bitmap.draw_text(x,0,width,height,item)
  222.         x += bitmap.text_size(item).width
  223.       end
  224.     end
  225.     return bitmap
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ● 解析文本
  229.   #--------------------------------------------------------------------------
  230.   def parse_text(str)
  231.     begin
  232.       last_text = str.clone
  233.       str.gsub!(/\\v\[(\d+)\]/i) { $game_variables[$1.to_i] }
  234.       str.gsub!(/\\g/i) { $game_party.gold.to_s }
  235.       str.gsub!(/\\itm\[(\d+)\]/i) { $game_party.item_number($1.to_i) }
  236.       str.gsub!(/\\wpn\[(\d+)\]/i) { $game_party.weapon_number($1.to_i) }
  237.       str.gsub!(/\\amr\[(\d+)\]/i) { $game_party.armor_number($1.to_i) }
  238.       str.gsub!(/\\1line{(.+?)}/im) { $1.delete("\n") }
  239.       str.gsub!(/\\eval{(.+?)}/im) { eval($1) }
  240.     end until str == last_text
  241.     str.gsub!(/\\n\[(\d+)\]/i) do
  242.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  243.     end
  244.     str.gsub!(/\n/){"\000\002n\000"}
  245.     str.gsub!(/\\\\/) { "\001" }
  246.     str.gsub!(/\\a\[([0-2])\]/i){ "\000\0027#{$1}" }
  247.     str.gsub!(/\\c\[(\d+)\]/i) { "\000\0020#{$1}\000" }
  248.     str.gsub!(/\\bold/i) { "\000\0021\000" }
  249.     str.gsub!(/\\italic/i) { "\000\0022\000" }
  250.     str.gsub!(/\\f\[(\w+)\]/i) { "\000\0023#{$1}\000" }
  251.     str.gsub!(/\\s\[(\d+)\]/i) { "\000\0024#{$1}\000" }
  252.     str.gsub!(/\\p\[(.+?)\]/i) { "\000\0025#{$1}\000" }
  253.     str.gsub!(/\\icon\[(.+?)\]/i){ "\000\0026#{$1}\000" }
  254.     str.gsub!(/\001/) {"\"}
  255.     @items = str.split("\000")
  256.     @items.delete("")
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ● 深度解析
  260.   #--------------------------------------------------------------------------
  261.   def parse_items
  262.     return unless @items.size > 0
  263.     bitmap = @cache
  264.     width, height, items = 1, 32, []
  265.     while item = @items.delete_at(0)
  266.       if item[/^\002([0-9a-z])(.*)/]
  267.         case (a = $1)
  268.         when '7'
  269.           @align = $2.to_i
  270.         when '0'
  271.           color = $2.to_i
  272.           bitmap.font.color = if color >= 0 and color <= 9
  273.             text_color(color)
  274.           elsif color == 8
  275.             disabled_color
  276.           elsif color == 9
  277.             system_color
  278.           end
  279.           items.push bitmap.font.color
  280.         when '1'
  281.           items.push :bold
  282.         when '2'
  283.           items.push :italic
  284.         when '3'
  285.           bitmap.font.name = $2
  286.           items.push [bitmap.font.name]
  287.         when '4'
  288.           bitmap.font.size = $2.to_i
  289.           items.push bitmap.font.size
  290.         when '5', '6'
  291.           item = (a == 5) ? RPG::Cache.picture($2) : RPG::Cache.icon($2)
  292.           if item.width > 408
  293.             item.dispose
  294.             items.unshift("[图片太大无法显示]")
  295.             next
  296.           elsif width + item.width > 408
  297.             @items.unshift(item)
  298.             break
  299.           end
  300.           items.push(item)
  301.           width += item.width + 4
  302.           height = item.height + 4 if item.height + 4 > height
  303.         when 'n'
  304.           break
  305.         end
  306.       else
  307.         str = ""
  308.         size = Rect.new(0, 0, 0, 0)
  309.         while s = item.slice!(/./)
  310.           size = bitmap.text_size(str + s)
  311.           if width + size.width > 408
  312.             item.insert(0, s)
  313.             break
  314.           else
  315.             str += s
  316.           end
  317.         end
  318.         if items[-1].is_a?(String)
  319.           items[-1] += str
  320.         else
  321.           items.push(str)
  322.         end
  323.         width += size.width
  324.         height = size.height + 4 if size.height + 4 > height
  325.         if item != ""
  326.           @items.unshift(item)
  327.           break
  328.         end
  329.       end
  330.     end
  331.     b = draw_line(width, height, items)
  332.     if @draw_y + b.height > 384
  333.       c = self.contents
  334.       self.contents = Bitmap.new(408, @draw_y + b.height)
  335.       self.contents.blt(0, 0, c, Rect.new(0,0,c.width, c.height))
  336.       c.dispose
  337.     end
  338.     x = 0
  339.     x = 204 - (b.width / 2) if @align == 1
  340.     x = 408 - b.width if @align == 2
  341.     self.contents.blt(x, @draw_y, b, Rect.new(0,0,b.width, b.height))
  342.     @draw_y += b.height
  343.   end
  344. end

  345. #===============================================================================
  346. # ■ 任务界面
  347. #===============================================================================
  348. class Scene_Mission
  349.   #--------------------------------------------------------------------------
  350.   # ● 初始化
  351.   #--------------------------------------------------------------------------
  352.   def initialize
  353.     @last_scene = $scene
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 主处理
  357.   #--------------------------------------------------------------------------
  358.   def main
  359.     screen = Spriteset_Map.new
  360.     @mission = $game_party.missions
  361.     @window1 = Window_Base.new(0,0,200,64)
  362.     @window1.contents = Bitmap.new(168,32)
  363.     @window1.contents.draw_text(0,0,168,32,"任务",1)
  364.     @window2 = Window_Base.new(200,0,440,64)
  365.     @window2.contents = Bitmap.new(408,32)
  366.     @window2.contents.draw_text(0,0,408,32,"任务说明",1)
  367.     @mission_window = Window_Mission.new
  368.     @mission_window.index = @mission.size - 1
  369.     @index = @mission_window.index
  370.     @info_window = Window_MissionInfo.new
  371.     @info_window.refresh(@mission[@index].info)
  372.     Graphics.transition
  373.     loop do
  374.       Graphics.update
  375.       Input.update
  376.       update
  377.       if $scene != self
  378.         break
  379.       end
  380.     end
  381.     Graphics.freeze
  382.     @window1.dispose
  383.     @window2.dispose
  384.     @mission_window.dispose
  385.     @info_window.dispose
  386.     screen.dispose
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # ● 刷新画面
  390.   #--------------------------------------------------------------------------
  391.   def update
  392.     @mission_window.update
  393.     @info_window.update
  394.     if @index != @mission_window.index
  395.       @index = @mission_window.index
  396.       @info_window.refresh(@mission[@index].info)
  397.     end
  398.     return update_mission if @mission_window.active
  399.     update_info
  400.   end
  401.   #--------------------------------------------------------------------------
  402.   # ● 刷新任务
  403.   #--------------------------------------------------------------------------
  404.   def update_mission
  405.     if Input.trigger?(Input::C)
  406.       $game_system.se_play($data_system.decision_se)
  407.       @mission_window.active = false
  408.       @info_window.oy = 0
  409.     elsif Input.trigger?(Input::B)
  410.       $game_system.se_play($data_system.cancel_se)
  411.       $scene = Scene_Menu.new(5)#$scene = @last_scene
  412.       return
  413.     end
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ● 刷新人物详情
  417.   #--------------------------------------------------------------------------
  418.   def update_info
  419.     @info_window.wait = 90
  420.     if Input.press?(Input::UP)
  421.       @info_window.oy -= 3
  422.       @info_window.oy = 0 if @info_window.oy < 0
  423.     elsif Input.press?(Input::DOWN)
  424.       @info_window.oy += 3
  425.       @info_window.oy = @info_window.oy_max if @info_window.oy > @info_window.oy_max
  426.     elsif Input.repeat?(Input::L)
  427.       $game_system.se_play($data_system.cursor_se)
  428.       @mission_window.index -= 1
  429.       @mission_window.index = $game_party.missions.size - 1 if @mission_window.index < 0
  430.     elsif Input.repeat?(Input::R)
  431.       $game_system.se_play($data_system.cursor_se)
  432.       @mission_window.index += 1
  433.       @mission_window.index = 0 if @mission_window.index >= $game_party.missions.size
  434.     elsif Input.trigger?(Input::B)
  435.       $game_system.se_play($data_system.cancel_se)
  436.       @mission_window.active = true
  437.       @info_window.scroll_up = false
  438.       @info_window.oy = 0
  439.     end
  440.   end
  441. end

  442. #===============================================================================
  443. # ■ 事件处理器
  444. #===============================================================================
  445. class Interpreter
  446.   alias orig_ec_mission execute_command if !defined?(orig_ec_mission)
  447.   alias orig_ec_tonghua execute_command if !defined?(orig_ec_tonghua)
  448.   #--------------------------------------------------------------------------
  449.   # ● 重定义执行事件命令
  450.   #--------------------------------------------------------------------------
  451.   def execute_command
  452.     if @index >= @list.size - 1
  453.       command_end
  454.       return true
  455.     end
  456.     @parameters = @list[@index].parameters
  457.     return command_108 if @list[@index].code == 108
  458.     return orig_ec_mission
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ● 注释
  462.   #--------------------------------------------------------------------------
  463.   def command_108
  464.     case @list[@index].parameters[0]
  465.     when (/^删除任务\[(\w+)\]$/)
  466.       $game_party.delete_mission($1)
  467.       return true
  468.     when (/^完成任务\[(\w+)\]$/)
  469.       $game_party.done_mission($1)
  470.       return true
  471.     when "删除所有任务"
  472.       $game_party.delete_all_mission
  473.       return true
  474.     when "完成所有任务"
  475.       $game_party.done_all_mission
  476.       return true
  477.     when (/^放弃任务\[(\w+)\]$/)
  478.       $game_party.fail_mission($1)
  479.       return true
  480.     when (/^恢复任务\[(\w+)\]$/)
  481.       $game_party.resume_mission($1)
  482.       return true
  483.     when "恢复所有任务"
  484.       $game_party.resume_all_mission
  485.       return true
  486.       
  487.     when (/^删除电话\[(\w+)\]$/)
  488.       $game_party.delete_tonghua($1)
  489.       return true
  490.     when (/^完成电话\[(\w+)\]$/)
  491.       $game_party.done_tonghua($1)
  492.       return true
  493.     when "删除所有电话"
  494.       $game_party.delete_all_tonghua
  495.       return true
  496.     when "完成所有电话"
  497.       $game_party.done_all_tonghua
  498.       return true
  499.     when (/^放弃电话\[(\w+)\]$/)
  500.       $game_party.fail_tonghua($1)
  501.       return true
  502.     when (/^恢复电话\[(\w+)\]$/)
  503.       $game_party.resume_tonghua($1)
  504.       return true
  505.     when "恢复所有电话"
  506.       $game_party.resume_all_tonghua
  507.       return true
  508.     end
  509.     text = @list[@index].parameters[0]
  510.     loop do
  511.       if @list[@index+1].code == 108 or @list[@index+1].code == 408
  512.         text += "\n" + @list[@index+1].parameters[0]
  513.       else
  514.         break
  515.       end
  516.       @index += 1
  517.     end
  518.     split = text.split("\n")
  519.     if (split[0] == "任务设置" or split[0] == "任务更新" or split[0] == "追加说明"  or  split[0] == "电话设置" or split[0] == "电话更新" or split[0] == "电话追加说明") and split.size >= 3
  520.       info , name = split[2] , split[1]
  521.       if split.size >= 4
  522.         for i in 3...split.size
  523.           info += "\n" + split[i]
  524.         end
  525.       end
  526.       $game_party.get_mission(name,info) if split[0] == "任务设置"
  527.       $game_party.update_mission(name,info) if split[0] == "任务更新"
  528.       $game_party.add_mission_info(name,info) if split[0] == "追加说明"
  529.       
  530.       $game_party.get_tonghua(name,info) if split[0] == "电话设置"
  531.       $game_party.update_tonghua(name,info) if split[0] == "电话更新"
  532.       $game_party.add_tonghua_info(name,info) if split[0] == "电话追加说明"
  533.     end
  534.    
  535.     return true
  536.   end
  537. end
复制代码
1.png
梦石
0
星屑
42345
在线时间
6022 小时
注册时间
2006-11-10
回帖
6975
发表于 2018-5-25 10:56:39 | 显示全部楼层
你依样画葫芦没画好啊,不能只单单改方法名称,这个脚本是由几个class组成的,可以试试把它们先分出来,然后看有重叠的部分合并到同一个地方去。


要得到选项的序号,可以直接到 149行这里

  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    @mission_window.update
    if @index != @mission_window.index
      @index = @mission_window.index
    $game_variables[编号] = @index  #代入N号变量
    end
    return update_mission if @mission_window.active
  end

加上这一句,接下来知道怎么做了吧

评分

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

查看全部评分

回复

使用道具 举报

梦石
0
星屑
4017
在线时间
604 小时
注册时间
2017-4-21
回帖
177
 楼主| 发表于 2018-5-25 12:36:16 | 显示全部楼层
灯笼菜刀王 发表于 2018-5-25 10:56
你依样画葫芦没画好啊,不能只单单改方法名称,这个脚本是由几个class组成的,可以试试把它们先分 ...

好吧,按照你的意思修改成功了。在一楼
在测试工程里面已经不会报错,不知道会不会有其他问题!!

另外,有没有办法把名字代入变量呢?因为妈妈可能是电话本里第一个,也可能是第二个
回复 0 1

使用道具 举报

梦石
0
星屑
39336
在线时间
11161 小时
注册时间
2009-3-15
回帖
4768
发表于 2018-5-25 13:47:10 | 显示全部楼层
本帖最后由 soulsaga 于 2018-5-25 14:48 编辑

电话脚本79行
  1. text = @tonghua[i].name
复制代码

加一行$game_variables[编号] = text if text == "妈妈叫你回来吃米水"

点评

不行,还是无法把名字代入变量。。  发表于 2018-5-25 17:44
I被吞了..  发表于 2018-5-25 14:49
报错undefined method “name”for #<Array:0xcbd3d30>  发表于 2018-5-25 14:26
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部