查看: 1018|回复: 2

请教物品分类脚本的问题

  [复制链接]
头像被屏蔽
梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-9-13
回帖
36
发表于 2008-12-3 19:37:35 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽

穿越一季:朔

梦石
0
星屑
50
在线时间
333 小时
注册时间
2007-4-11
回帖
5052

贵宾

发表于 2008-12-5 07:08:14 | 显示全部楼层
  1. #==============================================================================
  2. # ■ RPG追加定义,使用@符号分类
  3. #==============================================================================

  4. module RPG
  5.   class Weapon
  6.     def description
  7.       description = @description.split(/@/)[0]
  8.       return description != nil ? description : ''
  9.     end
  10.     def desc
  11.       desc = @description.split(/@/)[1]
  12.       return desc != nil ? desc : "武器"
  13.     end
  14.   end
  15.   class Item
  16.     def description
  17.       description = @description.split(/@/)[0]
  18.       return description != nil ? description : ''
  19.     end
  20.     def desc
  21.       desc = @description.split(/@/)[1]
  22.       return desc != nil ? desc : "物品"
  23.     end
  24.   end
  25.   class Armor
  26.     def description
  27.       description = @description.split(/@/)[0]
  28.       return description != nil ? description : ''
  29.     end
  30.     def desc
  31.       desc = @description.split(/@/)[1]
  32.       return desc != nil ? desc : "衣服"
  33.     end
  34.   end
  35. end

复制代码

class 为定义的类  如class Item 就是物品..可以自行修改添加

问题2
if @commands == []
      @commands.push("普通物品")
    end  

以上  

系统信息:本贴由本区版主认可为正确答案,66RPG感谢您的热情解答~
6R复活?别扯淡了.

柳柳一旦接手66RPG,我果断呵呵啊。
回复

使用道具 举报

头像被屏蔽
梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-9-13
回帖
36
 楼主| 发表于 2008-12-7 09:22:11 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部