设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3361|回复: 12
打印 上一主题 下一主题

[已经解决] 如何将复杂物品分类中@+从介绍调到名称?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
85
在线时间
578 小时
注册时间
2010-6-29
帖子
365
跳转到指定楼层
1
发表于 2011-4-4 15:49:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 凯蒂洛斯 于 2011-4-4 17:52 编辑

如题,复杂物品分类中@后的内容是要写在介绍里的,但是我又用了第二货币商店……所以求改。
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载请保留此信息
  3. # ————————————————————————————————————

  4. #==============================================================================
  5. # ■ Harts_Window_ItemTitle
  6. #==============================================================================

  7. class Harts_Window_ItemTitle < Window_Base
  8.   def initialize
  9.     super(0, 0, 160, 64)
  10.     self.contents = Bitmap.new(width - 32, height - 32)
  11.     self.contents.clear
  12.     self.contents.font.color = normal_color
  13.     self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
  14.   end
  15. end

  16. #==============================================================================
  17. # ■ Harts_Window_ItemCommand
  18. #==============================================================================

  19. class Harts_Window_ItemCommand < Window_Selectable
  20.   attr_accessor :commands
  21.   #--------------------------------------------------------------------------
  22.   # ● 初始化,生成commands窗口
  23.   #--------------------------------------------------------------------------
  24.   def initialize
  25.     super(0, 64, 160, 352)
  26.     self.contents = Bitmap.new(width - 32, height - 32)
  27.     @commands = []
  28.     #————————生成commands窗口
  29.     for i in 1...$data_items.size
  30.       if $game_party.item_number(i) > 0
  31.         push = true
  32.         for com in @commands
  33.           if com == $data_items[i].desc
  34.             push = false
  35.           end
  36.         end
  37.         if push == true
  38.           @commands.push($data_items[i].desc)
  39.         end
  40.       end
  41.     end
  42.     for i in 1...$data_weapons.size
  43.       if $game_party.weapon_number(i) > 0
  44.         push = true
  45.         for com in @commands
  46.           if com == $data_weapons[i].desc
  47.             push = false
  48.           end
  49.         end
  50.         if push == true
  51.           @commands.push($data_weapons[i].desc)
  52.         end
  53.       end
  54.     end
  55.     for i in 1...$data_armors.size
  56.       if $game_party.armor_number(i) > 0
  57.         push = true
  58.         for com in @commands
  59.           if com == $data_armors[i].desc
  60.             push = false
  61.           end
  62.         end
  63.         if push == true
  64.           @commands.push($data_armors[i].desc)
  65.         end
  66.       end
  67.     end
  68.     if @commands == []
  69.       @commands.push("普通物品")
  70.     end      
  71.     @item_max = @commands.size
  72.     refresh
  73.     self.index = 0
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   #--------------------------------------------------------------------------
  77.   def refresh
  78.     self.contents.clear
  79.     for i in 0...@item_max
  80.       draw_item(i, normal_color)
  81.     end
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   #--------------------------------------------------------------------------
  85.   def draw_item(index, color)
  86.     self.contents.font.color = color
  87.     y = index * 32
  88.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # 只描绘原文字
  92.   #--------------------------------------------------------------------------
  93.   def update_help
  94.     @help_window.set_text(@commands[self.index])
  95.   end
  96. end

  97. #==============================================================================
  98. # ■ Window_Item
  99. #==============================================================================

  100. class Harts_Window_ItemList < Window_Selectable
  101.   #--------------------------------------------------------------------------
  102.   #--------------------------------------------------------------------------
  103.   def initialize
  104.     super(160, 0, 480, 416)
  105.     refresh
  106.     self.index = 0
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   #--------------------------------------------------------------------------
  110.   def item
  111.     return @data[self.index]
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   #--------------------------------------------------------------------------
  115.   def refresh
  116.     if self.contents != nil
  117.       self.contents.dispose
  118.       self.contents = nil
  119.     end
  120.     @data = []
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   #--------------------------------------------------------------------------
  124.   def set_item(command)
  125.     refresh
  126.     for i in 1...$data_items.size
  127.       if $game_party.item_number(i) > 0 and $data_items[i].desc == command
  128.         @data.push($data_items[i])
  129.       end
  130.     end
  131.     for i in 1...$data_weapons.size
  132.       if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
  133.         @data.push($data_weapons[i])
  134.       end
  135.     end
  136.     for i in 1...$data_armors.size
  137.       if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
  138.         @data.push($data_armors[i])
  139.       end
  140.     end
  141.     @item_max = @data.size
  142.     if @item_max > 0
  143.       self.contents = Bitmap.new(width - 32, row_max * 32)
  144.       self.contents.clear
  145.       for i in 0...@item_max
  146.         draw_item(i)
  147.       end
  148.     end
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   #--------------------------------------------------------------------------
  152.   def item_number
  153.     return @item_max
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   #--------------------------------------------------------------------------
  157.   def draw_item(index)
  158.     item = @data[index]
  159.     case item
  160.     when RPG::Item
  161.       number = $game_party.item_number(item.id)
  162.     when RPG::Weapon
  163.       number = $game_party.weapon_number(item.id)
  164.     when RPG::Armor
  165.       number = $game_party.armor_number(item.id)
  166.     end
  167.     if item.is_a?(RPG::Item) and
  168.       $game_party.item_can_use?(item.id)
  169.       self.contents.font.color = normal_color
  170.     else
  171.       self.contents.font.color = disabled_color
  172.     end
  173.     x = 4
  174.     y = index * 32
  175.     bitmap = RPG::Cache.icon(item.icon_name)
  176.     opacity = self.contents.font.color == normal_color ? 255 : 128
  177.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  178.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  179.     self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
  180.     self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   #--------------------------------------------------------------------------
  184.   def update_help
  185.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  186.   end
  187. end

  188. #==============================================================================
  189. # ■ Harts_Scene_Item
  190. #==============================================================================

  191. class Scene_Item
  192.   #--------------------------------------------------------------------------
  193.   #--------------------------------------------------------------------------
  194.   def main
  195.     @itemtitle_window = Harts_Window_ItemTitle.new
  196.     @itemcommand_window = Harts_Window_ItemCommand.new
  197.     @command_index = @itemcommand_window.index
  198.     @itemlist_window = Harts_Window_ItemList.new
  199.     @itemlist_window.active = false
  200.     @help_window = Window_Help.new
  201.     @help_window.x = 0
  202.     @help_window.y = 416
  203.     @itemcommand_window.help_window = @help_window
  204.     @itemlist_window.help_window = @help_window
  205.     @target_window = Window_Target.new
  206.     @target_window.visible = false
  207.     @target_window.active = false
  208.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  209.     Graphics.transition
  210.     loop do
  211.       Graphics.update
  212.       Input.update
  213.       update
  214.       if $scene != self
  215.         break
  216.       end
  217.     end
  218.     Graphics.freeze
  219.     @itemtitle_window.dispose
  220.     @itemcommand_window.dispose
  221.     @itemlist_window.dispose
  222.     @help_window.dispose
  223.     @target_window.dispose
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   #--------------------------------------------------------------------------
  227.   def update
  228.     @itemtitle_window.update
  229.     @itemcommand_window.update
  230.     @itemlist_window.update
  231.     @help_window.update
  232.     @target_window.update
  233.     if @command_index != @itemcommand_window.index
  234.       @command_index = @itemcommand_window.index
  235.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  236.     end
  237.     if @itemcommand_window.active
  238.       update_itemcommand
  239.       return
  240.     end
  241.     if @itemlist_window.active
  242.       update_itemlist
  243.       return
  244.     end
  245.     if @target_window.active
  246.       update_target
  247.       return
  248.     end
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   #--------------------------------------------------------------------------
  252.   def update_itemcommand
  253.     if Input.trigger?(Input::B)
  254.       $game_system.se_play($data_system.cancel_se)
  255.       $scene = Scene_Menu.new(0)
  256.       return
  257.     end
  258.     if Input.trigger?(Input::C)
  259.       if @itemlist_window.item_number == 0
  260.         $game_system.se_play($data_system.buzzer_se)
  261.         return
  262.       end
  263.       $game_system.se_play($data_system.decision_se)
  264.       @itemcommand_window.active = false
  265.       @itemlist_window.active = true
  266.       @itemlist_window.index = 0
  267.       return
  268.     end
  269.   end
  270.   #--------------------------------------------------------------------------
  271.   #--------------------------------------------------------------------------
  272.   def update_itemlist
  273.     if Input.trigger?(Input::B)
  274.       $game_system.se_play($data_system.cancel_se)
  275.       @itemcommand_window.active = true
  276.       @itemlist_window.active = false
  277.       @itemlist_window.index = 0
  278.       @itemcommand_window.index = @command_index
  279.       return
  280.     end
  281.     if Input.trigger?(Input::C)
  282.       @item = @itemlist_window.item
  283.       unless @item.is_a?(RPG::Item)
  284.         $game_system.se_play($data_system.buzzer_se)
  285.         return
  286.       end
  287.       unless $game_party.item_can_use?(@item.id)
  288.         $game_system.se_play($data_system.buzzer_se)
  289.         return
  290.       end
  291.       $game_system.se_play($data_system.decision_se)
  292.       if @item.scope >= 3
  293.         @itemlist_window.active = false
  294.         @target_window.x = 304
  295.         @target_window.visible = true
  296.         @target_window.active = true
  297.         if @item.scope == 4 || @item.scope == 6
  298.           @target_window.index = -1
  299.         else
  300.           @target_window.index = 0
  301.         end
  302.       else
  303.         if @item.common_event_id > 0
  304.           $game_temp.common_event_id = @item.common_event_id
  305.           $game_system.se_play(@item.menu_se)
  306.             if @item.consumable
  307.               $game_party.lose_item(@item.id, 1)
  308.               @itemlist_window.draw_item(@itemlist_window.index)
  309.             end
  310.           $scene = Scene_Map.new
  311.           return
  312.         end
  313.       end
  314.       return
  315.     end
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   #--------------------------------------------------------------------------
  319.   def update_target
  320.     if Input.trigger?(Input::B)
  321.       $game_system.se_play($data_system.cancel_se)
  322.       unless $game_party.item_can_use?(@item.id)
  323.         @itemlist_window.refresh
  324.       end
  325.       @itemlist_window.active = true
  326.       @target_window.visible = false
  327.       @target_window.active = false
  328.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  329.       return
  330.     end
  331.     if Input.trigger?(Input::C)
  332.       if $game_party.item_number(@item.id) == 0
  333.         $game_system.se_play($data_system.buzzer_se)
  334.         return
  335.       end
  336.       if @target_window.index == -1
  337.         used = false
  338.         for i in $game_party.actors
  339.           used |= i.item_effect(@item)
  340.         end
  341.       end
  342.       if @target_window.index >= 0
  343.         target = $game_party.actors[@target_window.index]
  344.         used = target.item_effect(@item)
  345.       end
  346.       if used
  347.         $game_system.se_play(@item.menu_se)
  348.         if @item.consumable
  349.           $game_party.lose_item(@item.id, 1)
  350.           @itemlist_window.draw_item(@itemlist_window.index)
  351.           @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  352.         end
  353.         @target_window.refresh
  354.         if $game_party.all_dead?
  355.           $scene = Scene_Gameover.new
  356.           return
  357.         end
  358.         if @item.common_event_id > 0
  359.           $game_temp.common_event_id = @item.common_event_id
  360.           $scene = Scene_Map.new
  361.           return
  362.         end
  363.       end
  364.       unless used
  365.         $game_system.se_play($data_system.buzzer_se)
  366.       end
  367.     return
  368.     end
  369.   end
  370. end

  371. #==============================================================================
  372. # ■ RPG追加定义,使用@符号分类
  373. #==============================================================================

  374. module RPG
  375.   class Weapon
  376.     def description
  377.       description = @description.split(/@/)[0]
  378.       return description != nil ? description : ''
  379.     end
  380.     def desc
  381.       desc = @description.split(/@/)[1]
  382.       return desc != nil ? desc : "普通物品"
  383.     end
  384.   end
  385.   class Item
  386.     def description
  387.       description = @description.split(/@/)[0]
  388.       return description != nil ? description : ''
  389.     end
  390.     def desc
  391.       desc = @description.split(/@/)[1]
  392.       return desc != nil ? desc : "普通物品"
  393.     end
  394.   end
  395.   class Armor
  396.     def description
  397.       description = @description.split(/@/)[0]
  398.       return description != nil ? description : ''
  399.     end
  400.     def desc
  401.       desc = @description.split(/@/)[1]
  402.       return desc != nil ? desc : "普通物品"
  403.     end
  404.   end
  405. end
复制代码
代码在这里。
最后感谢enghao_lim君,沙漠点灰的范例还是有点问题……抱歉我最佳答案按早了。
为了四公主苦逼赚钱中。

Lv1.梦旅人

梦石
0
星屑
55
在线时间
323 小时
注册时间
2010-8-21
帖子
666
2
发表于 2011-4-4 16:10:26 | 只看该作者
回复 凯蒂洛斯 的帖子

是"第二货币商店"也用"@"?
现在物品分类要用"@+"?(麻烦说清楚一点...本人智商低),若是的话,
把你给的脚本最后几个  /@/   (共6个),改为 /@\+/ 就按 @+分类

点评

已解释  发表于 2011-4-4 16:38
>>猛戳>>MetalSagaR游戏主页<<这里<<
欢迎提供您的意见
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
85
在线时间
578 小时
注册时间
2010-6-29
帖子
365
3
 楼主| 发表于 2011-4-4 16:15:13 | 只看该作者
第二货币商店设置价格时要在介绍后面写@+数字
而复杂物品分类设置分类时要在介绍后面写@+类别名称
两个都是在介绍后面写,所以我想把复杂物品分类从在介绍后写@改成在名称后面写@。
为了四公主苦逼赚钱中。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
323 小时
注册时间
2010-8-21
帖子
666
4
发表于 2011-4-4 16:45:46 | 只看该作者
回复 凯蒂洛斯 的帖子
  1. module RPG
  2.   class Weapon
  3.     def name
  4.       name = @name.split(/@/)[0]
  5.       return name != nil ? name : ''
  6.     end
  7.     def desc
  8.       desc = @name.split(/@/)[1]
  9.       return desc != nil ? desc : "普通物品"
  10.     end
  11.   end
  12.   class Item
  13.     def name
  14.       name = @name.split(/@/)[0]
  15.       return name != nil ? name : ''
  16.     end
  17.     def desc
  18.       desc = @name.split(/@/)[1]
  19.       return desc != nil ? desc : "普通物品"
  20.     end
  21.   end
  22.   class Armor
  23.     def name
  24.       name = @name.split(/@/)[0]
  25.       return name != nil ? name : ''
  26.     end
  27.     def desc
  28.       desc = @name.split(/@/)[1]
  29.       return desc != nil ? desc : "普通物品"
  30.     end
  31.   end
  32. end
复制代码
也就是 description => name 就好了

点评

还是有问题啊……  发表于 2011-4-4 16:52
>>猛戳>>MetalSagaR游戏主页<<这里<<
欢迎提供您的意见
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
85
在线时间
578 小时
注册时间
2010-6-29
帖子
365
5
 楼主| 发表于 2011-4-4 16:52:06 | 只看该作者

成这样了……

点评

请无视后面的地图……  发表于 2011-4-4 16:55
为了四公主苦逼赚钱中。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
323 小时
注册时间
2010-8-21
帖子
666
6
发表于 2011-4-4 16:59:18 | 只看该作者
回复 凯蒂洛斯 的帖子

“回复剂”的名字是什么?,  回复剂@恢复药品 ??
我用过,不会出现啊...

点评

突然发现所有的代码都被被吞= =  发表于 2011-4-4 17:15
>>猛戳>>MetalSagaR游戏主页<<这里<<
欢迎提供您的意见
回复

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7946
在线时间
1182 小时
注册时间
2007-7-29
帖子
2055
7
发表于 2011-4-4 17:02:00 | 只看该作者
  1. module RPG
  2.   class Weapon
  3.     def description
  4.       description = @description.split(/@/)[0]
  5.       return description != nil ? description : ''
  6.     end
  7.     def desc
  8.       desc = @description.split(/@/)[1]
  9.       return desc != nil ? desc : "普通物品"
  10.     end
  11.     def sgprice
  12.       sgprice = @description.split(/@/)[2]
  13.       return sgprice != nil ? sgprice : 0
  14.     end
  15.   end
  16.   class Item
  17.     def description
  18.       description = @description.split(/@/)[0]
  19.       return description != nil ? description : ''
  20.     end
  21.     def desc
  22.       desc = @description.split(/@/)[1]
  23.       return desc != nil ? desc : "普通物品"
  24.     end
  25.     def sgprice
  26.       sgprice = @description.split(/@/)[2]
  27.       return sgprice != nil ? sgprice : 0
  28.     end
  29.   end
  30.   class Armor
  31.     def description
  32.       description = @description.split(/@/)[0]
  33.       return description != nil ? description : ''
  34.     end
  35.     def desc
  36.       desc = @description.split(/@/)[1]
  37.       return desc != nil ? desc : "普通物品"
  38.     end
  39.     def sgprice
  40.       sgprice = @description.split(/@/)[2]
  41.       return sgprice != nil ? sgprice : 0
  42.     end
  43.   end
  44. end
复制代码
把其中一边的module item删掉,然后另一边替换成这样。

设置方式:
物品详情@物品分类@第二种货币价格
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
85
在线时间
578 小时
注册时间
2010-6-29
帖子
365
8
 楼主| 发表于 2011-4-4 17:13:10 | 只看该作者
回复 enghao_lim 的帖子

用你的办法的话有冲突
为了四公主苦逼赚钱中。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
85
在线时间
578 小时
注册时间
2010-6-29
帖子
365
9
 楼主| 发表于 2011-4-4 17:14:34 | 只看该作者
对话框修改.rar (396.6 KB, 下载次数: 62)
不……好像是环状菜单的问题?
所有的代码都没被吞= =
为了四公主苦逼赚钱中。
回复

使用道具 举报

Lv2.观梦者

虚構歪曲

梦石
0
星屑
309
在线时间
1194 小时
注册时间
2010-12-18
帖子
3928

贵宾

10
发表于 2011-4-4 17:20:13 | 只看该作者
本帖最后由 忧雪の伤 于 2011-4-4 17:21 编辑

description的spilt改成name的……


  1. module RPG
  2.   class Weapon
  3.     def name
  4.       name = @name.split(/@/)[0]
  5.       return name != nil ? name : ''
  6.     end
  7.     def desc
  8.       desc = @name.split(/@/)[1]
  9.       return desc != nil ? desc : "普通物品"
  10.     end
  11.   end
  12.   class Item
  13.     def name
  14.       name = @name.split(/@/)[0]
  15.       return name != nil ? name : ''
  16.     end
  17.     def desc
  18.       desc = @name.split(/@/)[1]
  19.       return desc != nil ? desc : "普通物品"
  20.     end
  21.   end
  22.   class Armor
  23.     def name
  24.       name = @name.split(/@/)[0]
  25.       return name != nil ? name : ''
  26.     end
  27.     def desc
  28.       desc = @name.split(/@/)[1]
  29.       return desc != nil ? desc : "普通物品"
  30.     end
  31.   end
  32. end
复制代码
替换相关部分……

点评

和你一开始的一样是变成名字了……哦  发表于 2011-4-4 17:22
回复

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-1 17:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表