查看: 2246|回复: 1

[已经解决] 菜單教程的 if cn[0] == "[ DISCUZ_CODE_84 ]quot;

[复制链接]
梦石
0
星屑
129
在线时间
99 小时
注册时间
2012-11-7
回帖
27
发表于 2015-4-12 01:01:52 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 lanlan1923 于 2015-4-12 01:04 编辑

https://rpg.blue/thread-323665-1-1.html
想請問這個教程裡的描繪選項的部分

[pre lang="ruby"]cn = $game_actors[@list[index][:ext]].character_name
ci = $game_actors[@list[index][:ext]].character_index
cb = Cache.character(cn)
if cn[0] == "[        DISCUZ_CODE_43        ]quot;
else
end[/pre]

做到這一步時程式碼就變成紫色 再也沒辦法做下去了@@

紫色

紫色
就算抓下面改好的版本也一樣會出現紫色@@不知道是哪裡弄錯了?
謝謝

[pre lang="ruby"]class Window_NewMenuStatus < Window_Command
  #----------------------------------------------------------------------------
  # * 初始化
  #----------------------------------------------------------------------------
  def initialize
    super(160, 0)
  end
  #----------------------------------------------------------------------------
  # * 获取窗口的宽度
  #----------------------------------------------------------------------------
  def window_width
    return 384
  end
  #----------------------------------------------------------------------------
  # * 获取窗口的高度
  #----------------------------------------------------------------------------
  def window_height
    return 416
  end
  #----------------------------------------------------------------------------
  # * 更新内容
  #----------------------------------------------------------------------------
  def refresh
    super
    draw_actor_status
  end
  #----------------------------------------------------------------------------
  # * 生成指令列表
  #----------------------------------------------------------------------------
  def make_command_list
    for actor in $game_party.members
      s = "a[#{actor.id}]"
      add_command(actor.name, s.to_sym, !actor.death_state?, actor.id)
    end
  end
  #----------------------------------------------------------------------------
  # * 描绘选项
  #----------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect_for_text(index)
    b = Bitmap.new(rect.width, rect.height)
    cn = $game_actors[@list[index][:ext]].character_name
    ci = $game_actors[@list[index][:ext]].character_index
    cb = Cache.character(cn)
    if cn[0] == "[        DISCUZ_CODE_84        ]quot;
      cr = Rect.new
      cr.x = cb.width / 3
      cr.width = cb.width / 3
      cr.height = cb.height / 4
    else
      cr = Rect.new
      cr.x = ci % 4 * (cb.width / 4) + cb.width / 12
      cr.y = ci / 4 * (cb.height / 2)
      cr.width = cb.width / 12
      cr.height = cb.height / 8
    end
    b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr)
    unless command_enabled?(index)
      for y in 0...b.height
        for x in 0...b.width
          next if b.get_pixel(x, y).alpha == 0
          c = b.get_pixel(x, y)
          m = (c.red + c.green + c.blue) / 3
          b.set_pixel(x, y, Color.new(m, m, m, c.alpha))
        end
      end
    end
    self.contents.blt(rect.x, rect.y, b, b.rect)
    b.dispose
    cb.dispose
  end
  #----------------------------------------------------------------------------
  # * 获取项目的绘制矩形
  #----------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = self.contents.width / 4
    rect.height = 48
    rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width)
    rect.y = (index < 4 ? 0 : self.contents.height - rect.height)
    return rect
  end
  #----------------------------------------------------------------------------
  # * 描绘角色的状态
  #----------------------------------------------------------------------------
  def draw_actor_status
    actor = $game_actors[@list[@index][:ext]]
    y = item_rect_for_text(0).height + 5
    h = self.contents.height - 2 * (item_rect_for_text(0).height + 5)
    self.contents.clear_rect(Rect.new(0, y, self.contents.width, h))
    draw_actor_face(actor, 0, y)
    draw_actor_name(actor, 0, y)
    draw_actor_level(actor, 96, y)
    draw_actor_nickname(actor, 168, y)
    draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96)
    draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96)
    draw_actor_icons(actor, 96, y + 3 * line_height)
    for i in 0...6
      draw_actor_param(actor, 0, y + (4 + i) * line_height, i)
    end
    for i in 0...5
      draw_item_name(actor.equips, self.contents.width / 2, y + (4 + i) * line_height) if actor.equips != nil
    end
  end
  #----------------------------------------------------------------------------
  # * 选择项目
  #----------------------------------------------------------------------------
  def select(index)
    super
    draw_actor_status
  end
end[/pre]

无限の剣制

梦石
0
星屑
10450
在线时间
5019 小时
注册时间
2013-2-28
回帖
4942

开拓者贵宾

发表于 2015-4-12 01:18:15 | 显示全部楼层
本帖最后由 VIPArcher 于 2015-4-12 01:19 编辑

这个是老版本论坛代码解析带来的错误。
估计正确的是这样的
[pre lang="ruby"]class Window_NewMenuStatus < Window_Command
  #----------------------------------------------------------------------------
  # * 初始化
  #----------------------------------------------------------------------------
  def initialize
    super(160, 0)
  end
  #----------------------------------------------------------------------------
  # * 获取窗口的宽度
  #----------------------------------------------------------------------------
  def window_width
    return 384
  end
  #----------------------------------------------------------------------------
  # * 获取窗口的高度
  #----------------------------------------------------------------------------
  def window_height
    return 416
  end
  #----------------------------------------------------------------------------
  # * 更新内容
  #----------------------------------------------------------------------------
  def refresh
    super
    draw_actor_status
  end
  #----------------------------------------------------------------------------
  # * 生成指令列表
  #----------------------------------------------------------------------------
  def make_command_list
    for actor in $game_party.members
      s = "a[#{actor.id}]"
      add_command(actor.name, s.to_sym, !actor.death_state?, actor.id)
    end
  end
  #----------------------------------------------------------------------------
  # * 描绘选项
  #----------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect_for_text(index)
    b = Bitmap.new(rect.width, rect.height)
    cn = $game_actors[@list[index][:ext]].character_name
    ci = $game_actors[@list[index][:ext]].character_index
    cb = Cache.character(cn)
    if cn[0] == "$"
      cr = Rect.new
      cr.x = cb.width / 3
      cr.width = cb.width / 3
      cr.height = cb.height / 4
    else
      cr = Rect.new
      cr.x = ci % 4 * (cb.width / 4) + cb.width / 12
      cr.y = ci / 4 * (cb.height / 2)
      cr.width = cb.width / 12
      cr.height = cb.height / 8
    end
    b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr)
    unless command_enabled?(index)
      for y in 0...b.height
        for x in 0...b.width
          next if b.get_pixel(x, y).alpha == 0
          c = b.get_pixel(x, y)
          m = (c.red + c.green + c.blue) / 3
          b.set_pixel(x, y, Color.new(m, m, m, c.alpha))
        end
      end
    end
    self.contents.blt(rect.x, rect.y, b, b.rect)
    b.dispose
    cb.dispose
  end
  #----------------------------------------------------------------------------
  # * 获取项目的绘制矩形
  #----------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = self.contents.width / 4
    rect.height = 48
    rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width)
    rect.y = (index < 4 ? 0 : self.contents.height - rect.height)
    return rect
  end
  #----------------------------------------------------------------------------
  # * 描绘角色的状态
  #----------------------------------------------------------------------------
  def draw_actor_status
    actor = $game_actors[@list[@index][:ext]]
    y = item_rect_for_text(0).height + 5
    h = self.contents.height - 2 * (item_rect_for_text(0).height + 5)
    self.contents.clear_rect(Rect.new(0, y, self.contents.width, h))
    draw_actor_face(actor, 0, y)
    draw_actor_name(actor, 0, y)
    draw_actor_level(actor, 96, y)
    draw_actor_nickname(actor, 168, y)
    draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96)
    draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96)
    draw_actor_icons(actor, 96, y + 3 * line_height)
    for i in 0...6
      draw_actor_param(actor, 0, y + (4 + i) * line_height, i)
    end
    for i in 0...5
      draw_item_name(actor.equips, self.contents.width / 2, y + (4 + i) * line_height) if actor.equips != nil
    end
  end
  #----------------------------------------------------------------------------
  # * 选择项目
  #----------------------------------------------------------------------------
  def select(index)
    super
    draw_actor_status
  end
end[/pre]
未测试

点评

正常了,謝謝!  发表于 2015-4-12 03:54

评分

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

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部