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

Project1

 找回密码
 注册会员
搜索
查看: 1798|回复: 6

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3981
在线时间
603 小时
注册时间
2017-4-21
帖子
228
发表于 2018-5-25 01:00:51 | 显示全部楼层 |阅读模式

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

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

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

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

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

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

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



任务系统
RUBY 代码复制
  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. #===============================================================================
  27. class Game_Party
  28.   Mission = Struct.new(:id, :name, :info, :status)
  29.   alias org_init_mission initialize if !defined?(org_init_mission)
  30.   #--------------------------------------------------------------------------
  31.   # ● 重定义初始化
  32.   #--------------------------------------------------------------------------
  33.   def initialize
  34.     @mission = {}
  35.     org_init_mission
  36.   end
  37.  
  38.   def no_mission?
  39.     return @mission == {}
  40.   end
  41.  
  42.   def missions
  43.     if no_mission?
  44.       m = Mission.new(0,"没有任务"," ",0)
  45.       return [m]
  46.     end
  47.     return @mission.values.sort_by {|m|m.id}
  48.   end
  49.  
  50.   def get_mission(mission,info)
  51.     return if @mission.has_key?(mission)
  52.     id = missions[-1].id + 1
  53.     @mission[mission] = Mission.new(id,mission,info,0)
  54.   end
  55.  
  56.  
  57.   def done_mission(mission)
  58.     @mission[mission].status = 1 if @mission[mission].status == 0
  59.   end
  60.  
  61.  
  62.   def delete_mission(mission)
  63.     @mission.delete(mission)
  64.   end
  65.  
  66.  
  67.   def fail_mission(mission)
  68.     @mission[mission].status = 2 if @mission[mission].status == 0
  69.   end
  70.  
  71.  
  72.   def resume_mission(mission)
  73.     @mission[mission].status = 0 if @mission[mission].status == 2
  74.   end
  75.  
  76.  
  77.   def done_all_mission
  78.     @mission.each{|k,m|m.status = 1}
  79.   end
  80.  
  81.  
  82.   def update_mission(mission,info)
  83.     @mission[mission].info = info
  84.   end
  85.  
  86.  
  87.   def add_mission_info(mission,info)
  88.     @mission[mission].info += "\n" + info
  89.   end
  90.  
  91.  
  92.   def delete_all_mission
  93.     @mission = {}
  94.   end
  95.  
  96.  
  97.   def resume_all_mission
  98.     @mission.each{|k,m|m.status = 0 if m.status == 2}
  99.   end
  100.  
  101.  
  102. end
  103.  
  104. #===============================================================================
  105. # ■ 任务列表窗口
  106. #===============================================================================
  107. class Window_Mission < Window_Selectable
  108.   #--------------------------------------------------------------------------
  109.   # ● 初始化对象
  110.   #--------------------------------------------------------------------------
  111.   def initialize
  112.     super(0, 64, 200, 416)
  113.     self.index = 0
  114.     @mission = $game_party.missions
  115.     @item_max = @mission.size
  116.     if self.contents != nil
  117.       self.contents.dispose
  118.       self.contents = nil
  119.     end
  120.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  121.     for i in 0...@mission.size
  122.       t = @mission[i].status != 0
  123.       self.contents.font.color = t ? disabled_color : normal_color
  124.       text = @mission[i].name
  125.       self.contents.draw_text(4, i * 32, 160, 32, text.to_s)
  126.       self.contents.font.color = system_color
  127.       self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "□",1) unless $game_party.no_mission?
  128.       if @mission[i].status == 1
  129.         self.contents.font.color = crisis_color
  130.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "√",1)
  131.       elsif @mission[i].status == 2
  132.         self.contents.font.color = knockout_color
  133.         self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "×",1)
  134.       end
  135.     end
  136.   end
  137. end
  138.  
  139. #===============================================================================
  140. # ■ 任务详情窗口
  141. #===============================================================================
  142. class Window_MissionInfo < Window_Base
  143.   attr_accessor :wait
  144.   attr_accessor :scroll_up
  145.   #--------------------------------------------------------------------------
  146.   # ● 初始化对象
  147.   #--------------------------------------------------------------------------
  148.   def initialize
  149.     super(200,64,440,416)
  150.     self.contents =  Bitmap.new(408, 384)
  151.     @scroll_up = false
  152.     @wait = 90
  153.     @items = []
  154.     @progress = 0
  155.     @draw_y = 0
  156.     @align = 0
  157.     @cache = Bitmap.new(160,160)
  158.     @font = Font.new
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 刷新画面
  162.   #--------------------------------------------------------------------------
  163.   def update
  164.     super
  165.     parse_items if @items.size > 0
  166.     return if self.contents.height <= 384
  167.     return @wait -= 1 if @wait > 0
  168.     self.oy += @scroll_up ? -1 : 1
  169.     self.oy = 0 if self.oy < 0
  170.     self.oy = oy_max if self.oy > oy_max
  171.     if self.oy <= 0
  172.       @scroll_up = false
  173.       @wait = 60
  174.     elsif self.oy >= oy_max
  175.       @scroll_up = true
  176.       @wait = 60
  177.     end
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 释放
  181.   #--------------------------------------------------------------------------
  182.   def dispose
  183.     super
  184.     @cache.dispose
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 滚动最大值
  188.   #--------------------------------------------------------------------------
  189.   def oy_max
  190.     return self.contents.height - 384
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● 刷新
  194.   #--------------------------------------------------------------------------
  195.   def refresh(str)
  196.     str = str.clone
  197.     @scroll_up = false
  198.     @wait = 120
  199.     @draw_y = 0
  200.     @align = 0
  201.     @progress = 0
  202.     @lines = []
  203.     self.oy = 0
  204.     @cache.font = Font.new
  205.     @font = Font.new
  206.     self.contents.dispose
  207.     self.contents = Bitmap.new(408, 384)
  208.     parse_text(str)
  209.     12.times{parse_items}
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 描绘行
  213.   #--------------------------------------------------------------------------
  214.   def draw_line(width, height, items)
  215.     bitmap = Bitmap.new(width, height)
  216.     bitmap.font = @font
  217.     x = 0
  218.     for item in items
  219.       if item.is_a?(Color)
  220.         bitmap.font.color = item
  221.       elsif item.is_a?(Integer)
  222.         bitmap.font.size = item
  223.       elsif item.is_a?(Array)
  224.         bitmap.font.name = item[0] if item.size == 1
  225.       elsif item.is_a?(Bitmap)
  226.         bitmap.blt(x + 2, (height - item.height) / 2,
  227.                    item, Rect.new(0,0,item.width,item.height))
  228.         x += item.width + 4
  229.       elsif item == :bold
  230.         bitmap.font.italic = !bitmap.font.bold
  231.       elsif item == :italic
  232.         bitmap.font.italic = !bitmap.font.italic
  233.       else
  234.         bitmap.draw_text(x,0,width,height,item)
  235.         x += bitmap.text_size(item).width
  236.       end
  237.     end
  238.     return bitmap
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 解析文本
  242.   #--------------------------------------------------------------------------
  243.   def parse_text(str)
  244.     begin
  245.       last_text = str.clone
  246.       str.gsub!(/\\v\[(\d+)\]/i) { $game_variables[$1.to_i] }
  247.       str.gsub!(/\\g/i) { $game_party.gold.to_s }
  248.       str.gsub!(/\\itm\[(\d+)\]/i) { $game_party.item_number($1.to_i) }
  249.       str.gsub!(/\\wpn\[(\d+)\]/i) { $game_party.weapon_number($1.to_i) }
  250.       str.gsub!(/\\amr\[(\d+)\]/i) { $game_party.armor_number($1.to_i) }
  251.       str.gsub!(/\\1line{(.+?)}/im) { $1.delete("\n") }
  252.       str.gsub!(/\\eval{(.+?)}/im) { eval($1) }
  253.     end until str == last_text
  254.     str.gsub!(/\\n\[(\d+)\]/i) do
  255.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  256.     end
  257.     str.gsub!(/\n/){"\000\002n\000"}
  258.     str.gsub!(/\\\\/) { "\001" }
  259.     str.gsub!(/\\a\[([0-2])\]/i){ "\000\0027#{$1}" }
  260.     str.gsub!(/\\c\[(\d+)\]/i) { "\000\0020#{$1}\000" }
  261.     str.gsub!(/\\bold/i) { "\000\0021\000" }
  262.     str.gsub!(/\\italic/i) { "\000\0022\000" }
  263.     str.gsub!(/\\f\[(\w+)\]/i) { "\000\0023#{$1}\000" }
  264.     str.gsub!(/\\s\[(\d+)\]/i) { "\000\0024#{$1}\000" }
  265.     str.gsub!(/\\p\[(.+?)\]/i) { "\000\0025#{$1}\000" }
  266.     str.gsub!(/\\icon\[(.+?)\]/i){ "\000\0026#{$1}\000" }
  267.     str.gsub!(/\001/) {"\\"}
  268.     @items = str.split("\000")
  269.     @items.delete("")
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 深度解析
  273.   #--------------------------------------------------------------------------
  274.   def parse_items
  275.     return unless @items.size > 0
  276.     bitmap = @cache
  277.     width, height, items = 1, 32, []
  278.     while item = @items.delete_at(0)
  279.       if item[/^\002([0-9a-z])(.*)/]
  280.         case (a = $1)
  281.         when '7'
  282.           @align = $2.to_i
  283.         when '0'
  284.           color = $2.to_i
  285.           bitmap.font.color = if color >= 0 and color <= 9
  286.             text_color(color)
  287.           elsif color == 8
  288.             disabled_color
  289.           elsif color == 9
  290.             system_color
  291.           end
  292.           items.push bitmap.font.color
  293.         when '1'
  294.           items.push :bold
  295.         when '2'
  296.           items.push :italic
  297.         when '3'
  298.           bitmap.font.name = $2
  299.           items.push [bitmap.font.name]
  300.         when '4'
  301.           bitmap.font.size = $2.to_i
  302.           items.push bitmap.font.size
  303.         when '5', '6'
  304.           item = (a == 5) ? RPG::Cache.picture($2) : RPG::Cache.icon($2)
  305.           if item.width > 408
  306.             item.dispose
  307.             items.unshift("[图片太大无法显示]")
  308.             next
  309.           elsif width + item.width > 408
  310.             @items.unshift(item)
  311.             break
  312.           end
  313.           items.push(item)
  314.           width += item.width + 4
  315.           height = item.height + 4 if item.height + 4 > height
  316.         when 'n'
  317.           break
  318.         end
  319.       else
  320.         str = ""
  321.         size = Rect.new(0, 0, 0, 0)
  322.         while s = item.slice!(/./)
  323.           size = bitmap.text_size(str + s)
  324.           if width + size.width > 408
  325.             item.insert(0, s)
  326.             break
  327.           else
  328.             str += s
  329.           end
  330.         end
  331.         if items[-1].is_a?(String)
  332.           items[-1] += str
  333.         else
  334.           items.push(str)
  335.         end
  336.         width += size.width
  337.         height = size.height + 4 if size.height + 4 > height
  338.         if item != ""
  339.           @items.unshift(item)
  340.           break
  341.         end
  342.       end
  343.     end
  344.     b = draw_line(width, height, items)
  345.     if @draw_y + b.height > 384
  346.       c = self.contents
  347.       self.contents = Bitmap.new(408, @draw_y + b.height)
  348.       self.contents.blt(0, 0, c, Rect.new(0,0,c.width, c.height))
  349.       c.dispose
  350.     end
  351.     x = 0
  352.     x = 204 - (b.width / 2) if @align == 1
  353.     x = 408 - b.width if @align == 2
  354.     self.contents.blt(x, @draw_y, b, Rect.new(0,0,b.width, b.height))
  355.     @draw_y += b.height
  356.   end
  357. end
  358.  
  359. #===============================================================================
  360. # ■ 任务界面
  361. #===============================================================================
  362. class Scene_Mission
  363.   #--------------------------------------------------------------------------
  364.   # ● 初始化
  365.   #--------------------------------------------------------------------------
  366.   def initialize
  367.     @last_scene = $scene
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # ● 主处理
  371.   #--------------------------------------------------------------------------
  372.   def main
  373.     screen = Spriteset_Map.new
  374.     @mission = $game_party.missions
  375.     @window1 = Window_Base.new(0,0,200,64)
  376.     @window1.contents = Bitmap.new(168,32)
  377.     @window1.contents.draw_text(0,0,168,32,"任务",1)
  378.     @window2 = Window_Base.new(200,0,440,64)
  379.     @window2.contents = Bitmap.new(408,32)
  380.     @window2.contents.draw_text(0,0,408,32,"任务说明",1)
  381.     @mission_window = Window_Mission.new
  382.     @mission_window.index = @mission.size - 1
  383.     @index = @mission_window.index
  384.     @info_window = Window_MissionInfo.new
  385.     @info_window.refresh(@mission[@index].info)
  386.     Graphics.transition
  387.     loop do
  388.       Graphics.update
  389.       Input.update
  390.       update
  391.       if $scene != self
  392.         break
  393.       end
  394.     end
  395.     Graphics.freeze
  396.     @window1.dispose
  397.     @window2.dispose
  398.     @mission_window.dispose
  399.     @info_window.dispose
  400.     screen.dispose
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ● 刷新画面
  404.   #--------------------------------------------------------------------------
  405.   def update
  406.     @mission_window.update
  407.     @info_window.update
  408.     if @index != @mission_window.index
  409.       @index = @mission_window.index
  410.       @info_window.refresh(@mission[@index].info)
  411.     end
  412.     return update_mission if @mission_window.active
  413.     update_info
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ● 刷新任务
  417.   #--------------------------------------------------------------------------
  418.   def update_mission
  419.     if Input.trigger?(Input::C)
  420.       $game_system.se_play($data_system.decision_se)
  421.       @mission_window.active = false
  422.       @info_window.oy = 0
  423.     elsif Input.trigger?(Input::B)
  424.       $game_system.se_play($data_system.cancel_se)
  425.       $scene = Scene_Menu.new(5)#$scene = @last_scene
  426.       return
  427.     end
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ● 刷新人物详情
  431.   #--------------------------------------------------------------------------
  432.   def update_info
  433.     @info_window.wait = 90
  434.     if Input.press?(Input::UP)
  435.       @info_window.oy -= 3
  436.       @info_window.oy = 0 if @info_window.oy < 0
  437.     elsif Input.press?(Input::DOWN)
  438.       @info_window.oy += 3
  439.       @info_window.oy = @info_window.oy_max if @info_window.oy > @info_window.oy_max
  440.     elsif Input.repeat?(Input::L)
  441.       $game_system.se_play($data_system.cursor_se)
  442.       @mission_window.index -= 1
  443.       @mission_window.index = $game_party.missions.size - 1 if @mission_window.index < 0
  444.     elsif Input.repeat?(Input::R)
  445.       $game_system.se_play($data_system.cursor_se)
  446.       @mission_window.index += 1
  447.       @mission_window.index = 0 if @mission_window.index >= $game_party.missions.size
  448.     elsif Input.trigger?(Input::B)
  449.       $game_system.se_play($data_system.cancel_se)
  450.       @mission_window.active = true
  451.       @info_window.scroll_up = false
  452.       @info_window.oy = 0
  453.     end
  454.   end
  455. end
  456.  
  457. #===============================================================================
  458. # ■ 事件处理器
  459. #===============================================================================
  460. class Interpreter
  461.   alias orig_ec_mission execute_command if !defined?(orig_ec_mission)
  462.   alias orig_ec_tonghua execute_command if !defined?(orig_ec_tonghua)
  463.   #--------------------------------------------------------------------------
  464.   # ● 重定义执行事件命令
  465.   #--------------------------------------------------------------------------
  466.   def execute_command
  467.     if @index >= @list.size - 1
  468.       command_end
  469.       return true
  470.     end
  471.     @parameters = @list[@index].parameters
  472.     return command_108 if @list[@index].code == 108
  473.     return orig_ec_mission
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # ● 注释
  477.   #--------------------------------------------------------------------------
  478.   def command_108
  479.     case @list[@index].parameters[0]
  480.     when (/^删除任务\[(\w+)\]$/)
  481.       $game_party.delete_mission($1)
  482.       return true
  483.     when (/^完成任务\[(\w+)\]$/)
  484.       $game_party.done_mission($1)
  485.       return true
  486.     when "删除所有任务"
  487.       $game_party.delete_all_mission
  488.       return true
  489.     when "完成所有任务"
  490.       $game_party.done_all_mission
  491.       return true
  492.     when (/^放弃任务\[(\w+)\]$/)
  493.       $game_party.fail_mission($1)
  494.       return true
  495.     when (/^恢复任务\[(\w+)\]$/)
  496.       $game_party.resume_mission($1)
  497.       return true
  498.     when "恢复所有任务"
  499.       $game_party.resume_all_mission
  500.       return true
  501.  
  502.     when (/^删除电话\[(\w+)\]$/)
  503.       $game_party.delete_tonghua($1)
  504.       return true
  505.     when (/^完成电话\[(\w+)\]$/)
  506.       $game_party.done_tonghua($1)
  507.       return true
  508.     when "删除所有电话"
  509.       $game_party.delete_all_tonghua
  510.       return true
  511.     when "完成所有电话"
  512.       $game_party.done_all_tonghua
  513.       return true
  514.     when (/^放弃电话\[(\w+)\]$/)
  515.       $game_party.fail_tonghua($1)
  516.       return true
  517.     when (/^恢复电话\[(\w+)\]$/)
  518.       $game_party.resume_tonghua($1)
  519.       return true
  520.     when "恢复所有电话"
  521.       $game_party.resume_all_tonghua
  522.       return true
  523.     end
  524.     text = @list[@index].parameters[0]
  525.     loop do
  526.       if @list[@index+1].code == 108 or @list[@index+1].code == 408
  527.         text += "\n" + @list[@index+1].parameters[0]
  528.       else
  529.         break
  530.       end
  531.       @index += 1
  532.     end
  533.     split = text.split("\n")
  534.     if (split[0] == "任务设置" or split[0] == "任务更新" or split[0] == "追加说明"  or  split[0] == "电话设置" or split[0] == "电话更新" or split[0] == "电话追加说明") and split.size >= 3
  535.       info , name = split[2] , split[1]
  536.       if split.size >= 4
  537.         for i in 3...split.size
  538.           info += "\n" + split[i]
  539.         end
  540.       end
  541.       $game_party.get_mission(name,info) if split[0] == "任务设置"
  542.       $game_party.update_mission(name,info) if split[0] == "任务更新"
  543.       $game_party.add_mission_info(name,info) if split[0] == "追加说明"
  544.  
  545.       $game_party.get_tonghua(name,info) if split[0] == "电话设置"
  546.       $game_party.update_tonghua(name,info) if split[0] == "电话更新"
  547.       $game_party.add_tonghua_info(name,info) if split[0] == "电话追加说明"
  548.     end
  549.  
  550.     return true
  551.   end
  552. end
1.png

Lv5.捕梦者

梦石
0
星屑
37754
在线时间
5385 小时
注册时间
2006-11-10
帖子
6545
发表于 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 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

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

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

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

使用道具 举报

Lv5.捕梦者

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

电话脚本79行
RUBY 代码复制
  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
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-19 09:43

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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