查看: 1823|回复: 7

支持单张图标脚本和物品颜色脚本冲突

  [复制链接]
梦石
0
星屑
216
在线时间
77 小时
注册时间
2008-4-24
回帖
139
发表于 2008-12-28 01:01:26 | 显示全部楼层 |阅读模式

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

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

×
RT 支持单张图标脚本如果放在物品文字颜色脚本之上就不能显示单张图标了。
同样的,把支持单张图标脚本放在下面的话物品颜色就没有了。
哪位老大能整合一下?
此贴于 2008-12-30 13:25:59 被版主八云紫提醒,请楼主看到后对本贴做出回应。
版务信息:本贴由楼主自主结贴~
玩游戏总是不如做游戏的感觉好。所以喜欢做RPG
缅怀邓爷爷。

天仙

梦石
0
星屑
720
在线时间
184 小时
注册时间
2008-4-15
回帖
4872

贵宾

发表于 2008-12-28 04:44:53 | 显示全部楼层
沒有用alias的緣故
順便重寫了一下:
  1. class Window_Base
  2.   def draw_icon2(icon_file, x, y, enabled = true)
  3.     bitmap = Cache.load_bitmap("Graphics/Icons/", icon_file)
  4.     rect = Rect.new(0, 0, 24, 24)
  5.     self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  6.   end
  7.   alias draw_item_name_color_and_icon draw_item_name
  8.   def draw_item_name(item, x, y, enabled = true)
  9.     draw_item_name_color_and_icon(item, x, y, enabled)
  10.     if item != nil
  11.       if item.get_icon
  12.         draw_icon2(item.get_icon.to_s, x, y, enabled)
  13.       else
  14.         draw_icon(item.icon_index, x, y, enabled)
  15.       end
  16.       self.contents.font.color = item.get_color
  17.       self.contents.font.color.alpha = enabled ? 255 : 128
  18.       self.contents.draw_text(x + 24, y, 172, WLH, item.name)
  19.     end
  20.   end
  21. end
  22. class RPG::BaseItem
  23.   def get_icon
  24.     self.note.split(/[\r\n]+/).each { |line|
  25.       return $1 if line =~ /\[ICON (.*)\]/i
  26.     }
  27.     return nil
  28.   end
  29.   def get_color
  30.     self.note.split(/[\r\n]+/).each { |line|
  31.       if line =~ /\[(?:color) H([\da-f]{2})([\da-f]{2})([\da-f]{2})\]/i
  32.         return Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16) )
  33.       elsif line =~ /\[(?:color) (\d*)\]/
  34.         w = Window_Base.new(0, 0, 64, 64)
  35.         w.opacity = 0
  36.         return w.text_color($1.to_i)
  37.       else return Color.new(255, 255, 255)
  38.       end
  39.     }
  40.   end
  41. end
复制代码



用法:
在註釋裡面填寫
[icon 文件名]  繪製單張圖標
[color Hrrggbb]  物品名稱用 RRGGBB 色繪製,注意前面要加 H 代表是16進制碼
[color N]  物品名稱用windowskin的第 N 號顏色繪製

顏色填寫錯誤時,默認使用白色
VA脚本开工中...
偷窃脚本1.0 - 已完成
回复

使用道具 举报

梦石
0
星屑
216
在线时间
77 小时
注册时间
2008-4-24
回帖
139
 楼主| 发表于 2008-12-28 05:35:17 | 显示全部楼层
楼上的脚本有错误
显示can't convert array into color
玩游戏总是不如做游戏的感觉好。所以喜欢做RPG
缅怀邓爷爷。
回复

使用道具 举报

天仙

梦石
0
星屑
720
在线时间
184 小时
注册时间
2008-4-15
回帖
4872

贵宾

发表于 2008-12-28 05:42:28 | 显示全部楼层
第幾行

還有,你是怎麼設定的...
VA脚本开工中...
偷窃脚本1.0 - 已完成
回复

使用道具 举报

梦石
0
星屑
216
在线时间
77 小时
注册时间
2008-4-24
回帖
139
 楼主| 发表于 2008-12-29 16:55:05 | 显示全部楼层
我就是用的你的用法。今天不在家里没法测试了。等明天回去再看一遍
玩游戏总是不如做游戏的感觉好。所以喜欢做RPG
缅怀邓爷爷。
回复

使用道具 举报

梦石
0
星屑
216
在线时间
77 小时
注册时间
2008-4-24
回帖
139
 楼主| 发表于 2008-12-31 04:23:39 | 显示全部楼层
你的脚本 Line16 TypeError Occured
can't convert array into color
玩游戏总是不如做游戏的感觉好。所以喜欢做RPG
缅怀邓爷爷。
回复

使用道具 举报

天仙

梦石
0
星屑
720
在线时间
184 小时
注册时间
2008-4-15
回帖
4872

贵宾

发表于 2008-12-31 07:10:25 | 显示全部楼层
  1. class Window_Base
  2.   def draw_icon2(icon_file, x, y, enabled = true)
  3.     bitmap = Cache.load_bitmap("Graphics/Icons/", icon_file)
  4.     rect = Rect.new(0, 0, 24, 24)
  5.     self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  6.   end
  7.   alias draw_item_name_color_and_icon draw_item_name
  8.   def draw_item_name(item, x, y, enabled = true)
  9.     draw_item_name_color_and_icon(item, x, y, enabled)
  10.     if item != nil
  11.       if item.get_icon
  12.         draw_icon2(item.get_icon.to_s, x, y, enabled)
  13.       else
  14.         draw_icon(item.icon_index, x, y, enabled)
  15.       end
  16.       self.contents.font.color = item.get_color
  17.       self.contents.font.color.alpha = enabled ? 255 : 128
  18.       self.contents.draw_text(x + 24, y, 172, WLH, item.name)
  19.     end
  20.   end
  21. end
  22. class RPG::BaseItem
  23.   def get_icon
  24.     self.note.split(/[\r\n]+/).each { |line|
  25.       return $1 if line =~ /\[ICON (.*)\]/i
  26.     }
  27.     return nil
  28.   end
  29.   def get_color
  30.     self.note.split(/[\r\n]+/).each { |line|
  31.       if line =~ /\[(?:color) H([\da-f]{2})([\da-f]{2})([\da-f]{2})\]/i
  32.         return Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16) )
  33.       elsif line =~ /\[(?:color) (\d*)\]/
  34.         w = Window_Base.new(0, 0, 64, 64)
  35.         w.opacity = 0
  36.         return w.text_color($1.to_i)
  37.       else return Color.new(255, 255, 255)
  38.       end
  39.     }
  40.     return Color.new(255, 255, 255)
  41.   end
  42. end
复制代码

系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
VA脚本开工中...
偷窃脚本1.0 - 已完成
回复

使用道具 举报

梦石
0
星屑
216
在线时间
77 小时
注册时间
2008-4-24
回帖
139
 楼主| 发表于 2009-1-1 00:43:06 | 显示全部楼层
正确了,建议版主把这个脚本放到发布区吧。这个方法看起来可以解决很多冲突的脚本
玩游戏总是不如做游戏的感觉好。所以喜欢做RPG
缅怀邓爷爷。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部