查看: 2224|回复: 4

[已经过期] set_text(item_text)文字颜色如何更改?

[复制链接]
梦石
0
星屑
710
在线时间
663 小时
注册时间
2012-10-21
回帖
251
发表于 2014-11-10 11:40:12 | 显示全部楼层 |阅读模式

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

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

×
RT,我使用了物品颜色脚本,不同等级的物品有不同颜色。
但是,另一个脚本在物品名字后附加了物品类别的信息(比如短剑的物品会变成短剑-(剑)),这样一来物品名字的颜色就变白了,请问如何既加上物品类别信息,又能显示物品名字颜色?

这是物品类别信息的代码
[pre lang="ruby" line="1"]  alias :bm_base_si :set_item
  def set_item(item)
    return bm_base_si(item) unless BM::ADVANCED_HELP
    unless item; set_text("") ; return; end
    new_line = "\n"
    icon = BM::HELP_DISPLAY[0] ? '\i[' + item.icon_index.to_s + '] ' : ""
    name = BM::HELP_DISPLAY[1] ?   item.name  : ""
    #name = BM::HELP_DISPLAY[1] ? '\c[2]' + item.name + '\c[0]' : ""
    desc = BM::HELP_DISPLAY[2] ? item.description : ""
    if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)
      weight = $imported["XAIL-INVENTORY-WEIGHT"] ? weight = " - Weight: #{item.weight}." : ""
      durability = $imported["XAIL-ITEM-DURABILITY"] ? durability = " - Durability: #{item.durability} / #{item.max_durability}." : ""
    else weight = ""; durability = ""
    end
    if BM::HELP_DISPLAY[3]
      if item.is_a?(RPG::Weapon) ; item_type = " (" + Vocab.weapon_types(item.wtype_id) + ")" end
      if item.is_a?(RPG::Armor) ; item_type = " (" + Vocab.armor_types(item.atype_id) + ")" end
    else; item_type = ""
    end
    item_text = icon + name + item_type.to_s + weight + durability + new_line + desc
   
  
   
    set_text(item_text)
    change_color(normal_color)  

  end[/pre]

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-11-10 12:32:38 | 显示全部楼层
看物品颜色脚本是怎么更改的,照着那个脚本更改就好了

另外,你的脚本的第25行可以说明更改方法

点评

出错了,undefine cap 什么的……  发表于 2014-11-10 15:45
啥?(你的item.color是哪个脚本的方法?我写的那个物品颜色描绘脚本返回的是一个整数呢。  发表于 2014-11-10 15:40
我能调用item.color,但是那个是一个类似Color.new(186,85,211)这样的东西,请问怎么转换成\\[3]这样的控制符?  发表于 2014-11-10 15:35
参考第6行和第8行的做法.  发表于 2014-11-10 15:29
是可以,但是我要怎么调用物品名字颜色?  发表于 2014-11-10 15:28
回复

使用道具 举报

梦石
0
星屑
710
在线时间
663 小时
注册时间
2012-10-21
回帖
251
 楼主| 发表于 2014-11-10 15:09:11 | 显示全部楼层
taroxd 发表于 2014-11-10 12:32
看物品颜色脚本是怎么更改的,照着那个脚本更改就好了

另外,你的脚本的第25行可以说明更改方法 ...

第25行是我添加的,没啥作用……
回复

使用道具 举报

无限の剣制

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

开拓者贵宾

发表于 2014-11-10 15:31:38 | 显示全部楼层
本帖最后由 VIPArcher 于 2014-11-10 15:33 编辑

换这个物品颜色描绘脚本
https://rpg.blue/thread-372466-1-1.html
第7行改成
  1. name = BM::HELP_DISPLAY[1] ? "\c[#{item.color}]" + item.name + '\c[0]' : ""
复制代码
未测试

点评

在361行到363行那里有用到类似的用法。还有你楼下的那个脚本我似乎没看到会冲突的方法。  发表于 2014-11-10 16:03
参考这个脚本对这个物品颜色描绘脚本的使用http://rm.66rpg.com/thread-372430-1-1.html  发表于 2014-11-10 16:01
咱把你的脚本全改成item.color2了,但是还是出错,貌似是\c[#{item.color2}]这个不对?  发表于 2014-11-10 15:57
不能,方法都告诉你了,或许是我写的脚本和你的某脚本冲突了,你试试吧那个脚本里的RPG::BaseItem#color方法名改成不易冲突的名字  发表于 2014-11-10 15:52
抱歉打错……undefined upcase  发表于 2014-11-10 15:47
回复

使用道具 举报

梦石
0
星屑
710
在线时间
663 小时
注册时间
2012-10-21
回帖
251
 楼主| 发表于 2014-11-10 15:52:08 | 显示全部楼层
这是我的物品颜色脚本,包括物品前缀后缀什么的其他功能,你只看颜色部分就好

[pre lang="ruby" line="1"]#Weapon/Armor Randomization v1.2
#----------#
#Features: Allow the stats of an item to be randomized, yay! Also can tack
#           on random prefixes and suffixes. Oooh, fancy.
#
#Usage:    Basic Usage:
#
#           Note tags for weapons and armors:
#
#            <HP amount>  <HP% amount>  <ATK amount>  <ATK% amount>
#            <MP amount>  <MP% amount>  <DEF amount>  <DEF% amount>
#          <MAT amount>  <MAT% amount>  <MDF amount>  <MDF% amount>
#          <AGI amount>  <AGI% amount>  <LUK amount>  <LUK% amount>
#          <PRICE amount> <PRICE% amount>
#
#           Where amount is the amount to be randomly added on, with % being
#             a percentage instead of specific.
#           Examples: <HP 500>  or  <HP% 10>
#
#           Script calls:
#            add_armor(base_id, amount)
#            add_weapon(base_id, amount)
#         
#           These script calls create a new version of the item of the base_id
#            number, with randomized stats as set in their note.
#
#          Advanced Usage:
#         
#           Note tags for weapons and armors:
#
#            <SUFFIX# rarity>    <PREFIX# rarity>
#
#           Where # is the id number of the affix and rarity is the chance of it
#            occuring with 100 always occuring and 1 almost never occuring.
#            Multiple affix notes can be added and the first one that passes it's
#            rarity chance will be added.
#           Examples: <PREFIX1 50>  or  <SUFFIX2 90>
#
#          The Complicated Part: (Affixes)
#           See that AFFIXES hash down there? That's where you set these up.
#           Basic setup is:
#             ID => { :symbol => data, },
#           You can have as many different symbols in there as you want, each
#            seperated by a comma, and don't forget the comma between each AFFIX
#            id.
#
#           Usable Symbols:
#          :name = "name"
#
#   :hp,   :mp,   :atk,   :def,   :mat,   :mdf,   :agi,   :luk    (random bonus)
#   :Shp,  :Smp,  :Satk,  :Sdef,  :Smat,  :Smdf,  :Sagi,  :Sluk   (static bonus)
#   :hpP,  :mpP,  :atkP,  :defP,  :matP,  :mdfP,  :agiP,  :lukP   (random % bonus)
#   :ShpP, :SmpP, :SatkP, :SdefP, :SmatP, :SmdfP, :SagiP, :SlukP  (static % bonus)
#
#   :price, :Sprice, :priceP, :SpriceP
#
#       each of these goes :symbol = value
#
#          The fun part, :features
#           You can have as many features as you want, set up in an array:
#           :features = [[code, id, value],[code, id, value]] etc...
#          But what are the codes, ids, and values?? Don't worry, I found out:
#
#           Element Rate   = 11, element_id, float value
#           Debuff Rate    = 12, param_id, float value
#           State Rate     = 13, state_id, float value
#           State Resist   = 14, state_id, 0
#
#           Parameter      = 21, param_id, float value
#           Ex-Parameter   = 22, exparam_id, float value
#           Sp-Parameter   = 23, spparam_id, float value
#
#           Atk Element    = 31, element_id, 0
#           Atk State      = 32, state_id, float value
#           Atk Speed      = 33, 0, value
#           Atk Times+     = 34, 0, value
#
#           Add Skill Type = 41, skill_type, 0
#          Seal Skill Type = 42, skill_type, 0
#           Add Skill      = 43, skill_id, 0
#           Seal Skill     = 44, skill_id, 0
#
#           Equip Weapon   = 51, weapon_skill, 0
#           Equip Armor    = 52, armor_skill, 0
#           Fix Equip      = 53, item_type, 0
#           Seal Equip     = 54, item_type, 0
#           Slot Type      = 55, 1, 0
#
#           Action Times+  = 61, 0, value
#           Special Flag   = 62, flag_id, 0
#          Collapse Effect = 62, flag_id, 0
#           Party Ability  = 63, flag_id, 0
#
#     float value = percentage value where 1 = 100%, 0.75 = 75%, and 1.25 = 125%
#     param_id, 0=hp, 1=mp, 2=atk, 3=def, 4=mat, 5=mdf, 6=agi, 7=luk
#
#     Examples: [21, 2, 1.5] which would increase atk to 150%
#               [62, 0, 0]   which makes the item give the auto-battle flag
#               [32, 1, 0.5] which gives a 50% of applying death state
#
#----------#
#-- Script by: Vlue of Daimonious Tails
#
#- Questions or comments can be:
#    posted on the thread for the script
#    given by email: sumptuaryspade@live.ca
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#    posed on site: daimonioustails.wordpress.com
#
#--- Free to use in any project with credit given

AFFIXES = { 1 => { :name => "Bronze ",
                   :SatkP => 10,},
                  
            2 => { :name => "Iron ",
                   :SatkP => 30,},
                  
            3 => { :name => "Steel ",
                   :SatkP => 60,},
                  
            4 => { :name => "Mithril ",
                   :SatkP => 100,},
                  
            5 => { :name => "Harder Mithril ",
                   :SatkP => 150,},
                  
            100 => { :name => " of Power",
                   :SatkP => 40,
                   :SmatP => 40,},
                  
            200 => { :name => " of Defense",
                   :SdefP => 40,
                   :SmdfP => 40,},
                  
            300 => { :name => " of Speed",
                   :SagiP => 80,},
                  
            400 => { :name => " of Better Speed",
                   :features => [[34,0,2]],},
            }
           
#If true, then weapons and armors dropped by enemies will be randomized
RANDOM_ENEMY_DROPS = true

class Game_Interpreter
  def add_weapon(id, am)
    $game_party.add_weapon(id, am)
  end
  def add_armor(id, am)
    $game_party.add_armor(id, am)
  end
end

class Game_Party
  alias rig_initialize initialize
  def initialize
    rig_initialize
    @saved_weapons = $data_weapons
    @saved_armors = $data_armors
  end
  attr_accessor :saved_weapons
  attr_accessor :saved_armors
  def add_weapon(id, amount)
    item = Marshal.load(Marshal.dump($data_weapons[id]))
    item.id = $data_weapons.size
    edit_item(item)
    edit_affixes(item)
    $data_weapons.each do |base_item|
      next if base_item.nil?
      if ( item.params == base_item.params &&
          item.price == base_item.price &&
          item.name == base_item.name )
        $game_party.gain_item(base_item, amount)
        return
      end
    end
    $data_weapons.push(item)
    $game_party.gain_item(item, amount)
  end
  def add_armor(id, amount)
    item = Marshal.load(Marshal.dump($data_armors[id]))
    item.id = $data_armors.size
    edit_item(item)
    edit_affixes(item)
    $data_armors.push(item)
    $game_party.gain_item(item, amount)
  end
  def edit_affixes(item)
    note = item.note.clone
    while note.include?("<SUF")
      id = note =~ /<SUFFIX(\d+) (\d+)>/
      if !AFFIXES[$~[1].to_i].nil?
        break if add_affix(item, $~[1].to_i, false) if rand(100) < $2.to_i
        note[id] = "N"
      else
        msgbox("Affix #" + $1 + " doesn't exist. \nItem creation failed.")
        return
      end
    end
    while note.include?("<PRE")
      id = note =~ /<PREFIX(\d+) (\d+)>/
      if !AFFIXES[$~[1].to_i].nil?
        break if add_affix(item, $~[1].to_i, true) if rand(100) < $2.to_i
        note[id] = "N"
      else
        msgbox("Affix #" + $1 + " doesn't exist. \nItem creation failed.")
        return
      end
    end
  end
  def add_affix(item, id, prefix)
    affix = AFFIXES[id]
    if prefix && !affix[:name].nil?
      item.name = affix[:name] + item.name
    elsif !affix[:name].nil?
      item.name = item.name + affix[:name]
    end
    item.params[0] += rand(affix[:hp]) if !affix[:hp].nil?
    item.params[1] += rand(affix[:mp]) if !affix[:mp].nil?
    item.params[2] += rand(affix[:atk]) if !affix[:atk].nil?
    item.params[3] += rand(affix[:def]) if !affix[:def].nil?
    item.params[4] += rand(affix[:mat]) if !affix[:mat].nil?
    item.params[5] += rand(affix[:mdf]) if !affix[:mdf].nil?
    item.params[6] += rand(affix[:agi]) if !affix[:agi].nil?
    item.params[7] += rand(affix[:luk]) if !affix[:luk].nil?
    item.price += rand(affix[:price]) if !affix[:price].nil?
   
    item.params[0] += affix[:Shp] if !affix[:Shp].nil?
    item.params[1] += affix[:Smp] if !affix[:Smp].nil?
    item.params[2] += affix[:Satk] if !affix[:Satk].nil?
    item.params[3] += affix[:Sdef] if !affix[:Sdef].nil?
    item.params[4] += affix[:Smat] if !affix[:Smat].nil?
    item.params[5] += affix[:Smdf] if !affix[:Smdf].nil?
    item.params[6] += affix[:Sagi] if !affix[:Sagi].nil?
    item.params[7] += affix[:Sluk] if !affix[:Sluk].nil?
    item.price += affix[:Sprice] if !affix[:Sprice].nil?
   
    item.params[0] += item.params[0] * (rand(affix[:hpP])) / 100 if !affix[:hpP].nil?
    item.params[1] += item.params[1] * (rand(affix[:mpP])) / 100 if !affix[:mpP].nil?
    item.params[2] += item.params[2] * (rand(affix[:atkP])) / 100 if !affix[:atkP].nil?
    item.params[3] += item.params[3] * (rand(affix[:defP])) / 100 if !affix[:defP].nil?
    item.params[4] += item.params[4] * (rand(affix[:matP])) / 100 if !affix[:matP].nil?
    item.params[5] += item.params[5] * (rand(affix[:mdfP])) / 100 if !affix[:mdfP].nil?
    item.params[6] += item.params[6] * (rand(affix[:agiP])) / 100 if !affix[:agiP].nil?
    item.params[7] += item.params[7] * (rand(affix[:lukP])) / 100 if !affix[:lukP].nil?
    item.price += item.price * (rand(affix[:priceP])) / 100 if !affix[:priceP].nil?
   
    item.params[0] += item.params[0] * affix[:ShpP] / 100 if !affix[:ShpP].nil?
    item.params[1] += item.params[1] * affix[:SmpP] / 100 if !affix[:SmpP].nil?
    item.params[2] += item.params[2] * affix[:SatkP] / 100 if !affix[:SatkP].nil?
    item.params[3] += item.params[3] * affix[:SdefP] / 100 if !affix[:SdefP].nil?
    item.params[4] += item.params[4] * affix[:SmatP] / 100 if !affix[:SmatP].nil?
    item.params[5] += item.params[5] * affix[:SmdfP] / 100 if !affix[:SmdfP].nil?
    item.params[6] += item.params[6] * affix[:SagiP] / 100 if !affix[:SagiP].nil?
    item.params[7] += item.params[7] * affix[:SlukP] / 100 if !affix[:SlukP].nil?
    item.price += item.price * affix[:SpriceP] / 100 if !affix[:SpriceP].nil?
   
    if !affix[:features].nil?
      for feature in affix[:features]
        new_feature = RPG::BaseItem::Feature.new(feature[0], feature[1], feature[2])
        item.features.push(new_feature)
      end
    end
   
    return true
  end
  def edit_item(item)
    item.note =~ /<HP (\d+)>/
    item.params[0] += rand($~[1].to_i) if $~
    item.note =~ /<MP (\d+)>/
    item.params[1] += rand($~[1].to_i) if $~
    item.note =~ /<ATK (\d+)>/
    item.params[2] += rand($~[1].to_i) if $~
    item.note =~ /<DEF (\d+)>/
    item.params[3] += rand($~[1].to_i) if $~
    item.note =~ /<MAT (\d+)>/
    item.params[4] += rand($~[1].to_i) if $~
    item.note =~ /<MDF (\d+)>/
    item.params[5] += rand($~[1].to_i) if $~
    item.note =~ /<AGI (\d+)>/
    item.params[6] += rand($~[1].to_i) if $~
    item.note =~ /<LUK (\d+)>/
    item.params[7] += rand($~[1].to_i) if $~
    item.note =~ /<PRICE (\d+)>/
    item.price += rand($~[1].to_i) if $~
   
    item.note =~ /<HP% (\d+)>/
    item.params[0] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
    item.note =~ /<MP% (\d+)>/
    item.params[1] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
    item.note =~ /<ATK% (\d+)>/
    item.params[2] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
    item.note =~ /<DEF% (\d+)>/
    item.params[3] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
    item.note =~ /<MAT% (\d+)>/
    item.params[4] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
    item.note =~ /<MDF% (\d+)>/
    item.params[5] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
    item.note =~ /<AGI% (\d+)>/
    item.params[6] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
    item.note =~ /<LUK% (\d+)>/
    item.params[7] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
    item.note =~ /<PRICE% (\d+)>/
    item.price += item.price * (rand($~[1].to_i)) / 100 if $~
  end
end

module BattleManager
  def self.gain_drop_items
    $game_troop.make_drop_items.each do |item|
      if RANDOM_ENEMY_DROPS
        if item.is_a?(RPG::Weapon)
          $game_party.add_weapon(item.id, 1)
          item = $data_weapons[-1]
        elsif item.is_a?(RPG::Armor)
          $game_party.add_armor(item.id, 1)
          item = $data_armors[-1]
        else
          $game_party.gain_item(item, 1)
        end
      else
        $game_party.gain_item(item, 1)
      end
      $game_message.add(sprintf(Vocab::ObtainItem, item.name))
    end
    wait_for_message
  end
end

class Scene_Load
  alias rig_on_load_success on_load_success
  def on_load_success
    rig_on_load_success
    $data_weapons = $game_party.saved_weapons
    $data_armors = $game_party.saved_armors
  end
end[/pre]
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部