Project1
标题:
请教物品分类脚本的问题
[打印本页]
作者:
wangjile
时间:
2008-12-3 19:37
提示:
作者被禁止或删除 内容自动屏蔽
作者:
塑望
时间:
2008-12-5 07:08
#==============================================================================
# ■ RPG追加定义,使用@符号分类
#==============================================================================
module RPG
class Weapon
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "武器"
end
end
class Item
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "物品"
end
end
class Armor
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "衣服"
end
end
end
复制代码
class 为定义的类 如class Item 就是物品..可以自行修改添加
问题2
if
@commands == []
@commands.push("普通物品")
end
以上
[LINE]1,#dddddd[/LINE]
系统信息:本贴由本区版主认可为正确答案,66RPG感谢您的热情解答~
作者:
wangjile
时间:
2008-12-7 09:22
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1