Project1

标题: 求助:事件脚本出现这个 [打印本页]

作者: 游戏解说小汪    时间: 2018-1-23 19:13
标题: 求助:事件脚本出现这个
本帖最后由 游戏解说小汪 于 2018-1-23 19:15 编辑


如图
执行的脚本如下
RUBY 代码复制
  1. #用法:
  2. #领取任务:$game_party.get_task(任意数字,任务名称,任务描述)
  3. #完成任务:$game_party.finish_task(领取任务时设定的数字)
  4. #如:前面有事件$game_party.get_task(1,"测试","只是测试")
  5. #后面完成任务的脚本就是$game_party.finish_task(1)
  6.  
  7. #召唤任务界面:SceneManager.call(Scene_Task)
  8.  
  9.  
  10. class Task
  11.   attr_reader :desc
  12.   attr_reader :finished
  13.   def initialize(origin_name,desc)
  14.     @origin_name = origin_name
  15.     @desc = desc
  16.     @finished = false
  17.   end
  18.   def name
  19.     if @finished
  20.       return @origin_name + "(完成)"
  21.     else
  22.       return @origin_name
  23.     end
  24.   end
  25.   def finish
  26.     @finished = true
  27.   end
  28.  
  29. end
  30.  
  31. class Game_Party < Game_Unit
  32.   alias old_init initialize
  33.   def initialize
  34.     old_init
  35.     @tasks = {}
  36.   end
  37.   def get_task(i,name,desc)
  38.     @tasks[i]=Task.new(name,desc)
  39.   end
  40.   def have_task?(i)
  41.     @tasks[i] != nil
  42.   end
  43.   def finish_task(i)
  44.     @tasks[i].finish if have_task?(i)
  45.   end
  46.   def unfinished_tasks
  47.     n = []
  48.     for i in @tasks.values
  49.       next if i.finished
  50.       n.push(i)
  51.     end
  52.     return n
  53.   end
  54.   def finished_tasks
  55.     n = []
  56.     for i in @tasks.values
  57.       next unless i.finished
  58.       n.push(i)
  59.     end
  60.     return n
  61.   end
  62. end
  63.  
  64. class Window_Task_Type < Window_HorzCommand
  65.   #--------------------------------------------------------------------------
  66.   # ● オブジェクト初期化
  67.   #--------------------------------------------------------------------------
  68.   def initialize
  69.     super(0, 0)
  70.     activate
  71.   end
  72.   def window_width
  73.     return Graphics.width
  74.   end
  75.   def col_max
  76.     return 3
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● コマンドリストの作成
  80.   #--------------------------------------------------------------------------
  81.   def make_command_list
  82.     add_command("未完成任务",  :unfinished_task)
  83.     add_command("已完成任务", :finished_task)
  84.     add_command("取消", :cancel)
  85.   end
  86. end
  87.  
  88. class Window_TaskLeft < Window_Selectable
  89.   attr_reader :finished
  90.   def initialize
  91.     super(0,48,160,Graphics.height - 48)
  92.     create_contents
  93.     @finished = false
  94.     @index = 0
  95.     refresh
  96.     deactivate
  97.   end
  98.   def set_finish(finish)
  99.     @finished = finish
  100.     set_item_max
  101.   end
  102.   def item_max
  103.     return @item_max != nil ? @item_max : 0
  104.   end
  105.   def set_item_max
  106.     if @finished
  107.       @item_max = $game_party.finished_tasks.size
  108.     else
  109.       @item_max = $game_party.unfinished_tasks.size
  110.     end
  111.   end
  112.  
  113.   def refresh
  114.     set_item_max
  115.     super
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 項目の描画
  119.   #--------------------------------------------------------------------------
  120.   def draw_item(index)
  121.     text = ""
  122.     unless @finished
  123.       if $game_party.unfinished_tasks[index] != nil
  124.         text = $game_party.unfinished_tasks[index].name
  125.       end
  126.     else
  127.       if $game_party.finished_tasks[index] != nil
  128.         text = $game_party.finished_tasks[index].name  
  129.       end
  130.     end
  131.     draw_text(item_rect_for_text(index), text)
  132.   end
  133.  
  134. end
  135.  
  136. class Window_TaskRight < Window_Base
  137.   attr_reader :left_index
  138.   def initialize
  139.     super(160,48,Graphics.width - 160,Graphics.height - 48)
  140.     create_contents
  141.     @left_index = 0
  142.     @finished = false
  143.     refresh
  144.   end
  145.   def set_index(i)
  146.     @left_index = i
  147.     refresh
  148.   end
  149.   def set_finish(i)
  150.     @finished = i
  151.   end
  152.  
  153.   def refresh
  154.     contents.clear
  155.     draw_desc
  156.   end
  157.   def draw_desc
  158.     if @finished
  159.       if $game_party.finished_tasks[@left_index] != nil
  160.         draw_text_ex(0,0,$game_party.finished_tasks[@left_index].desc)
  161.       end
  162.     else
  163.       if $game_party.unfinished_tasks[@left_index] != nil
  164.         draw_text_ex(0,0,$game_party.unfinished_tasks[@left_index].desc)
  165.       end
  166.     end
  167.   end
  168.  
  169. end
  170.  
  171. class Scene_Task < Scene_Base
  172.   def start
  173.     super
  174.     create_task_type_window
  175.     create_left_window
  176.     create_right_window
  177.   end
  178.   def update
  179.     super
  180.     if @left_window.active
  181.       if Input.trigger?(:B)
  182.         @left_window.deactivate
  183.         @task_type_window.activate
  184.       end
  185.       if Input.trigger?(:UP) || Input.trigger?(:DOWN)
  186.         @right_window.set_finish(@left_window.finished)
  187.         @right_window.set_index(@left_window.index)
  188.       end
  189.     end
  190.   end
  191.  
  192.   def terminate
  193.     super
  194.   end
  195.   def create_task_type_window
  196.     @task_type_window = Window_Task_Type.new
  197.     @task_type_window.set_handler(:unfinished_task,method(:view_unfinished_task))
  198.     @task_type_window.set_handler(:finished_task,method(:view_finished_task))
  199.     @task_type_window.set_handler(:cancel,method(:return_scene))
  200.   end
  201.   def create_left_window
  202.     @left_window = Window_TaskLeft.new
  203.     @left_window.set_finish(false)
  204.     @left_window.refresh
  205.   end
  206.   def create_right_window
  207.     @right_window = Window_TaskRight.new
  208.     @right_window.refresh
  209.   end
  210.   def view_unfinished_task
  211.     @left_window.set_finish(false)
  212.     @left_window.refresh
  213.     @left_window.activate
  214.     @task_type_window.deactivate
  215.     @right_window.set_finish(false)
  216.     @right_window.set_index(@left_window.index)
  217.   end
  218.   def view_finished_task
  219.     @left_window.set_finish(true)
  220.     @left_window.refresh
  221.     @left_window.activate
  222.     @task_type_window.deactivate
  223.     @right_window.set_finish(true)
  224.     @right_window.set_index(@left_window.index)
  225.   end
  226.  
  227. end

作者: a1103855226    时间: 2018-1-23 19:42
哇!!!!!
作者: 余音·魔眼    时间: 2018-1-23 20:13
你的事件脚本出现了语法上的错误,检查下脚本是不是英文输入法的那种




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1