Project1

标题: 如何能在装备介绍里显示变量? [打印本页]

作者: CR~    时间: 2014-11-26 22:17
标题: 如何能在装备介绍里显示变量?
密斯利尔剑
最高级的剑。战士可以装备。(变量1的值,5)
作者: RyanBern    时间: 2014-11-27 08:52
脚本功能:在1号武器介绍后面追加1号变量的数值,2号武器介绍后面追加2号变量的数值,以此类推。
RUBY 代码复制
  1. module RPG
  2.   class Weapon
  3.     alias rb_description_20141127 description
  4.     def description
  5.       return rb_description_20141127 + $game_variables[self.id].to_s
  6.     end
  7.   end
  8. end

作者: CR~    时间: 2014-11-29 21:19
其实我是想要在装备介绍显示套装的集齐数量。。
密斯利尔套装,一共5件,变量1的值是角色身上穿的该套装的数量。
最高级的剑。战士可以装备。(变量1的值,5)
作者: 芯☆淡茹水    时间: 2014-11-29 21:43
本帖最后由 芯☆淡茹水 于 2014-11-29 21:52 编辑

RyanBern.each do | chd114 |
  1. module RPG
  2.   class Weapon
  3.     def description
  4.       @description.gsub!(/\\[Vv]\[([0-9]+)\]/){$game_variables[$1.to_i]}
  5.       return @description
  6.     end
  7.   end
  8.   class Armor
  9.     def description
  10.       @description.gsub!(/\\[Vv]\[([0-9]+)\]/){$game_variables[$1.to_i]}
  11.       return @description
  12.     end
  13.   end
  14. end
复制代码
end


最高级的剑。战士可以装备。(\v[1],5)
作者: CR~    时间: 2014-11-30 14:34
芯☆淡茹水 发表于 2014-11-29 21:43
RyanBern.each do | chd114 |end

跟装备颜色有冲突,,,怎么把他们俩整合在一起。。?
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. #


  5. # 脚本功能:给不同物品显示不同颜色,类似暗黑破坏神,比如套装为绿色,超级为金色
  6. #           可以更改的种类包括物品、防具、特技、武器。
  7. #
  8. # 使用方法:对于不想为白色表示的物品,在描述中最后添加@6,@4一类的即可。
  9. #           数字为颜色编号,和对话框中的一样。
  10. # ——————————————————————————————————————
  11. module RPG
  12.   class Skill
  13.     def description
  14.       description = @description.split(/@/)[0]
  15.       return description != nil ? description : ''
  16.     end
  17.     def name_color_66RPG
  18.       name_color = @description.split(/@/)[1]
  19.       return name_color != nil ? name_color.to_i : 0
  20.     end
  21.   end
  22.   class Weapon
  23.     def description
  24.       description = @description.split(/@/)[0]
  25.       return description != nil ? description : ''
  26.     end
  27.     def name_color_66RPG
  28.       name_color = @description.split(/@/)[1]
  29.       return name_color != nil ? name_color.to_i : 0
  30.     end
  31.   end
  32.   class Item
  33.     def description
  34.       description = @description.split(/@/)[0]
  35.       return description != nil ? description : ''
  36.     end
  37.     def name_color_66RPG
  38.       name_color = @description.split(/@/)[1]
  39.       return name_color != nil ? name_color.to_i : 0
  40.     end
  41.   end
  42.   class Armor
  43.     def description
  44.       description = @description.split(/@/)[0]
  45.       return description != nil ? description : ''
  46.     end
  47.     def name_color_66RPG
  48.       name_color = @description.split(/@/)[1]
  49.       return name != nil ? name_color.to_i : 0
  50.     end
  51.   end
  52. end
  53. # ——————————————————————————————————————
  54. # 本脚本原创自www.66rpg.com,转载请保留此信息
  55. # ——————————————————————————————————————
  56. class Window_Base < Window
  57.   #--------------------------------------------------------------------------
  58.   # ● 描绘物品名
  59.   #     item : 物品
  60.   #     x    : 描画目标 X 坐标
  61.   #     y    : 描画目标 Y 坐标
  62.   #--------------------------------------------------------------------------
  63.   def draw_item_name(item, x, y)
  64.     if item == nil
  65.       return
  66.     end
  67.     bitmap = RPG::Cache.icon(item.icon_name)
  68.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  69.     self.contents.font.color = text_color(item.name_color_66RPG)
  70.     self.contents.draw_text(x + 28, y, 212, 32, item.name.to_s)
  71.   end
  72. end
  73. # ——————————————————————————————————————
  74. # 本脚本原创自www.66rpg.com,转载请保留此信息
  75. # ——————————————————————————————————————
  76. class Window_Item
  77.   #--------------------------------------------------------------------------
  78.   # ● 描绘项目
  79.   #     index : 项目编号
  80.   #--------------------------------------------------------------------------
  81.   def draw_item(index)
  82.     item = @data[index]
  83.     case item
  84.     when RPG::Item
  85.       number = $game_party.item_number(item.id)
  86.     when RPG::Weapon
  87.       number = $game_party.weapon_number(item.id)
  88.     when RPG::Armor
  89.       number = $game_party.armor_number(item.id)
  90.     end
  91.     if item.is_a?(RPG::Item) and
  92.        $game_party.item_can_use?(item.id)
  93.       self.contents.font.color = text_color(item.name_color_66RPG)
  94.     else
  95.       self.contents.font.color = disabled_color
  96.     end
  97.     x = 4 + index % 2 * (288 + 32)
  98.     y = index / 2 * 32
  99.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  100.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  101.     bitmap = RPG::Cache.icon(item.icon_name)
  102.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  103.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  104.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  105.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  106.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  107.   end
  108. end
  109. # ——————————————————————————————————————
  110. # 本脚本原创自www.66rpg.com,转载请保留此信息
  111. # ——————————————————————————————————————
  112. class Window_EquipItem < Window_Selectable
  113.   #--------------------------------------------------------------------------
  114.   # ● 项目的描绘
  115.   #     index : 项目符号
  116.   #--------------------------------------------------------------------------
  117.   def draw_item(index)
  118.     item = @data[index]
  119.     x = 4 + index % 2 * (0)
  120.     y = index / 1 * 32
  121.     case item
  122.     when RPG::Weapon
  123.       number = $game_party.weapon_number(item.id)
  124.     when RPG::Armor
  125.       number = $game_party.armor_number(item.id)
  126.     end
  127.     bitmap = RPG::Cache.icon(item.icon_name)
  128.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  129.     self.contents.font.color = text_color(item.name_color_66RPG)
  130.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  131.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  132.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  133.   end
  134. end
  135. # ——————————————————————————————————————
  136. # 本脚本原创自www.66rpg.com,转载请保留此信息
  137. # ——————————————————————————————————————
  138. class Window_ShopBuy < Window_Selectable
  139.   #--------------------------------------------------------------------------
  140.   # ● 描绘羡慕
  141.   #     index : 项目编号
  142.   #--------------------------------------------------------------------------
  143.   def draw_item(index)
  144.     item = @data[index]
  145.     # 获取物品所持数
  146.     case item
  147.     when RPG::Item
  148.       number = $game_party.item_number(item.id)
  149.     when RPG::Weapon
  150.       number = $game_party.weapon_number(item.id)
  151.     when RPG::Armor
  152.       number = $game_party.armor_number(item.id)
  153.     end
  154.     # 价格在所持金以下、并且所持数不是 99 的情况下为普通颜色
  155.     # 除此之外的情况设置为无效文字色
  156.     if item.price <= $game_party.gold and number < 99
  157.       self.contents.font.color = text_color(item.name_color_66RPG)
  158.     else
  159.       self.contents.font.color = disabled_color
  160.     end
  161.     x = 4
  162.     y = index * 32
  163.     rect = Rect.new(x, y, self.width - 32, 32)
  164.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  165.     bitmap = RPG::Cache.icon(item.icon_name)
  166.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  167.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  168.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  169.     self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  170.   end
  171. end
  172. # ——————————————————————————————————————
  173. # 本脚本原创自www.66rpg.com,转载请保留此信息
  174. # ——————————————————————————————————————
  175. class Window_ShopSell < Window_Selectable
  176.   #--------------------------------------------------------------------------
  177.   # ● 描绘项目
  178.   #     index : 项目标号
  179.   #--------------------------------------------------------------------------
  180.   def draw_item(index)
  181.     item = @data[index]
  182.     case item
  183.     when RPG::Item
  184.       number = $game_party.item_number(item.id)
  185.     when RPG::Weapon
  186.       number = $game_party.weapon_number(item.id)
  187.     when RPG::Armor
  188.       number = $game_party.armor_number(item.id)
  189.     end
  190.     # 可以卖掉的显示为普通颜色、除此之外设置成无效文字颜色
  191.     if item.price > 0
  192.       self.contents.font.color = text_color(item.name_color_66RPG)
  193.     else
  194.       self.contents.font.color = disabled_color
  195.     end
  196.     x = 4 + index % 2 * (288 + 32)
  197.     y = index / 2 * 32
  198.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  199.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  200.     bitmap = RPG::Cache.icon(item.icon_name)
  201.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  202.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  203.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  204.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  205.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  206.   end
  207. end
  208.    
  209. # ——————————————————————————————————————
  210. # 本脚本原创自www.66rpg.com,转载请保留此信息
  211. # ——————————————————————————————————————
  212. class Window_Skill
  213.   #--------------------------------------------------------------------------
  214.   # ● 描绘项目
  215.   #     index : 项目编号
  216.   #--------------------------------------------------------------------------
  217.   def draw_item(index)
  218.     skill = @data[index]
  219.     if @actor.skill_can_use?(skill.id)
  220.       self.contents.font.color = text_color(skill.name_color_66RPG)
  221.     else
  222.       self.contents.font.color = disabled_color
  223.     end
  224.     x = 4 + index % 2 * (288 + 32)
  225.     y = index / 2 * 32
  226.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  227.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  228.     bitmap = RPG::Cache.icon(skill.icon_name)
  229.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  230.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  231.     self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  232.     self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  233.   end
  234. end
  235. #==============================================================================
  236. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  237. #==============================================================================
复制代码

作者: 芯☆淡茹水    时间: 2014-11-30 16:23
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. #


  5. # 脚本功能:给不同物品显示不同颜色,类似暗黑破坏神,比如套装为绿色,超级为金色
  6. #           可以更改的种类包括物品、防具、特技、武器。
  7. #
  8. # 使用方法:对于不想为白色表示的物品,在描述中最后添加@6,@4一类的即可。
  9. #           数字为颜色编号,和对话框中的一样。
  10. # ——————————————————————————————————————
  11. module RPG
  12.   class Skill
  13.     def description
  14.       description = @description.split(/@/)[0]
  15.       return description != nil ? description : ''
  16.     end
  17.     def name_color_66RPG
  18.       name_color = @description.split(/@/)[1]
  19.       return name_color != nil ? name_color.to_i : 0
  20.     end
  21.   end
  22.   class Weapon
  23.     def description
  24.       description = @description.split(/@/)[0]
  25.       description = description != nil ? description : ''
  26.       description.gsub!(/\\[Vv]\[([0-9]+)\]/){$game_variables[$1.to_i]}
  27.       return description
  28.     end
  29.     def name_color_66RPG
  30.       name_color = @description.split(/@/)[1]
  31.       return name_color != nil ? name_color.to_i : 0
  32.     end
  33.   end
  34.   class Item
  35.     def description
  36.       description = @description.split(/@/)[0]
  37.       return description != nil ? description : ''
  38.     end
  39.     def name_color_66RPG
  40.       name_color = @description.split(/@/)[1]
  41.       return name_color != nil ? name_color.to_i : 0
  42.     end
  43.   end
  44.   class Armor
  45.     def description
  46.       description = @description.split(/@/)[0]
  47.       description = description != nil ? description : ''
  48.       description.gsub!(/\\[Vv]\[([0-9]+)\]/){$game_variables[$1.to_i]}
  49.       return description
  50.     end
  51.     def name_color_66RPG
  52.       name_color = @description.split(/@/)[1]
  53.       return name != nil ? name_color.to_i : 0
  54.     end
  55.   end
  56. end
  57. # ——————————————————————————————————————
  58. # 本脚本原创自www.66rpg.com,转载请保留此信息
  59. # ——————————————————————————————————————
  60. class Window_Base < Window
  61.   #--------------------------------------------------------------------------
  62.   # ● 描绘物品名
  63.   #     item : 物品
  64.   #     x    : 描画目标 X 坐标
  65.   #     y    : 描画目标 Y 坐标
  66.   #--------------------------------------------------------------------------
  67.   def draw_item_name(item, x, y)
  68.     if item == nil
  69.       return
  70.     end
  71.     bitmap = RPG::Cache.icon(item.icon_name)
  72.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  73.     self.contents.font.color = text_color(item.name_color_66RPG)
  74.     self.contents.draw_text(x + 28, y, 212, 32, item.name.to_s)
  75.   end
  76. end
  77. # ——————————————————————————————————————
  78. # 本脚本原创自www.66rpg.com,转载请保留此信息
  79. # ——————————————————————————————————————
  80. class Window_Item
  81.   #--------------------------------------------------------------------------
  82.   # ● 描绘项目
  83.   #     index : 项目编号
  84.   #--------------------------------------------------------------------------
  85.   def draw_item(index)
  86.     item = @data[index]
  87.     case item
  88.     when RPG::Item
  89.       number = $game_party.item_number(item.id)
  90.     when RPG::Weapon
  91.       number = $game_party.weapon_number(item.id)
  92.     when RPG::Armor
  93.       number = $game_party.armor_number(item.id)
  94.     end
  95.     if item.is_a?(RPG::Item) and
  96.        $game_party.item_can_use?(item.id)
  97.       self.contents.font.color = text_color(item.name_color_66RPG)
  98.     else
  99.       self.contents.font.color = disabled_color
  100.     end
  101.     x = 4 + index % 2 * (288 + 32)
  102.     y = index / 2 * 32
  103.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  104.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  105.     bitmap = RPG::Cache.icon(item.icon_name)
  106.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  107.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  108.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  109.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  110.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  111.   end
  112. end
  113. # ——————————————————————————————————————
  114. # 本脚本原创自www.66rpg.com,转载请保留此信息
  115. # ——————————————————————————————————————
  116. class Window_EquipItem < Window_Selectable
  117.   #--------------------------------------------------------------------------
  118.   # ● 项目的描绘
  119.   #     index : 项目符号
  120.   #--------------------------------------------------------------------------
  121.   def draw_item(index)
  122.     item = @data[index]
  123.     x = 4 + index % 2 * (0)
  124.     y = index / 1 * 32
  125.     case item
  126.     when RPG::Weapon
  127.       number = $game_party.weapon_number(item.id)
  128.     when RPG::Armor
  129.       number = $game_party.armor_number(item.id)
  130.     end
  131.     bitmap = RPG::Cache.icon(item.icon_name)
  132.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  133.     self.contents.font.color = text_color(item.name_color_66RPG)
  134.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  135.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  136.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  137.   end
  138. end
  139. # ——————————————————————————————————————
  140. # 本脚本原创自www.66rpg.com,转载请保留此信息
  141. # ——————————————————————————————————————
  142. class Window_ShopBuy < Window_Selectable
  143.   #--------------------------------------------------------------------------
  144.   # ● 描绘羡慕
  145.   #     index : 项目编号
  146.   #--------------------------------------------------------------------------
  147.   def draw_item(index)
  148.     item = @data[index]
  149.     # 获取物品所持数
  150.     case item
  151.     when RPG::Item
  152.       number = $game_party.item_number(item.id)
  153.     when RPG::Weapon
  154.       number = $game_party.weapon_number(item.id)
  155.     when RPG::Armor
  156.       number = $game_party.armor_number(item.id)
  157.     end
  158.     # 价格在所持金以下、并且所持数不是 99 的情况下为普通颜色
  159.     # 除此之外的情况设置为无效文字色
  160.     if item.price <= $game_party.gold and number < 99
  161.       self.contents.font.color = text_color(item.name_color_66RPG)
  162.     else
  163.       self.contents.font.color = disabled_color
  164.     end
  165.     x = 4
  166.     y = index * 32
  167.     rect = Rect.new(x, y, self.width - 32, 32)
  168.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  169.     bitmap = RPG::Cache.icon(item.icon_name)
  170.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  171.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  172.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  173.     self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  174.   end
  175. end
  176. # ——————————————————————————————————————
  177. # 本脚本原创自www.66rpg.com,转载请保留此信息
  178. # ——————————————————————————————————————
  179. class Window_ShopSell < Window_Selectable
  180.   #--------------------------------------------------------------------------
  181.   # ● 描绘项目
  182.   #     index : 项目标号
  183.   #--------------------------------------------------------------------------
  184.   def draw_item(index)
  185.     item = @data[index]
  186.     case item
  187.     when RPG::Item
  188.       number = $game_party.item_number(item.id)
  189.     when RPG::Weapon
  190.       number = $game_party.weapon_number(item.id)
  191.     when RPG::Armor
  192.       number = $game_party.armor_number(item.id)
  193.     end
  194.     # 可以卖掉的显示为普通颜色、除此之外设置成无效文字颜色
  195.     if item.price > 0
  196.       self.contents.font.color = text_color(item.name_color_66RPG)
  197.     else
  198.       self.contents.font.color = disabled_color
  199.     end
  200.     x = 4 + index % 2 * (288 + 32)
  201.     y = index / 2 * 32
  202.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  203.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  204.     bitmap = RPG::Cache.icon(item.icon_name)
  205.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  206.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  207.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  208.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  209.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  210.   end
  211. end
  212.    
  213. # ——————————————————————————————————————
  214. # 本脚本原创自www.66rpg.com,转载请保留此信息
  215. # ——————————————————————————————————————
  216. class Window_Skill
  217.   #--------------------------------------------------------------------------
  218.   # ● 描绘项目
  219.   #     index : 项目编号
  220.   #--------------------------------------------------------------------------
  221.   def draw_item(index)
  222.     skill = @data[index]
  223.     if @actor.skill_can_use?(skill.id)
  224.       self.contents.font.color = text_color(skill.name_color_66RPG)
  225.     else
  226.       self.contents.font.color = disabled_color
  227.     end
  228.     x = 4 + index % 2 * (288 + 32)
  229.     y = index / 2 * 32
  230.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  231.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  232.     bitmap = RPG::Cache.icon(skill.icon_name)
  233.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  234.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  235.     self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  236.     self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  237.   end
  238. end
  239. #==============================================================================
  240. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  241. #==============================================================================
复制代码





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