Lv3.寻梦者
○赛
您需要 登录 才可以下载或查看,没有帐号?注册会员
0.1.png (1.12 KB, 下载次数: 19)
下载附件 保存到相册
2014-5-25 12:24 上传
0.2.png (26.38 KB, 下载次数: 20)
2014-5-25 12:23 上传
查看全部评分
使用道具 举报
Lv5.捕梦者 (管理员)
老黄鸡
module ZhengQi NAME_PART1 = ["疾风","烈焰","狂雷","飞天","旋风"] NAME_PART2 = ["升龙","裂空","惊涛","三连","圣灵"] NAME_PART3 = ["斩","击","拳","刺","爪"] def self.get_weapon_name ret = NAME_PART1[rand(NAME_PART1.size)] ret += NAME_PART2[rand(NAME_PART2.size)] ret += NAME_PART3[rand(NAME_PART3.size)] return ret endend
module ZhengQi NAME_PART1 = ["疾风","烈焰","狂雷","飞天","旋风"] NAME_PART2 = ["升龙","裂空","惊涛","三连","圣灵"] NAME_PART3 = ["斩","击","拳","刺","爪"] def self.get_weapon_name ret = NAME_PART1[rand(NAME_PART1.size)] ret += NAME_PART2[rand(NAME_PART2.size)] ret += NAME_PART3[rand(NAME_PART3.size)] return ret end end
$game_variables[1] = ZhengQi.get_weapon_name
1.png (2.92 KB, 下载次数: 11)
2014-5-25 13:06 上传
Lv3.寻梦者 (版主)
…あたしは天使なんかじゃないわ
class Symbol # Ruby1.9 之后自带这个定义,并且比这个更加完善,支持带参数的调用 def to_proc Proc.new {|obj| obj.send(self) } endend class Array # 随机取出一个元素。默认脚本中的sample(n)可以随机取出n个元素 def sample slice rand size endend module ZhengQi NAME_LIST = [ %w[疾风 烈焰 狂雷 飞天 旋风], %w[升龙 裂空 惊涛 三连 圣灵], %w[斩 击 拳 刺 爪] ] # 将之后定义的方法设为private,并复制成一个模块方法 # 这方法1.8有没有呢……………… module_function def make_name NAME_LIST.collect(&:sample).join end end # 这样一来,事件脚本里就可以省略“ZhengQi.”了# 参考Ruby的Math模块class Game_Interpreter include ZhengQiend
class Symbol # Ruby1.9 之后自带这个定义,并且比这个更加完善,支持带参数的调用 def to_proc Proc.new {|obj| obj.send(self) } end end class Array # 随机取出一个元素。默认脚本中的sample(n)可以随机取出n个元素 def sample slice rand size end end module ZhengQi NAME_LIST = [ %w[疾风 烈焰 狂雷 飞天 旋风], %w[升龙 裂空 惊涛 三连 圣灵], %w[斩 击 拳 刺 爪] ] # 将之后定义的方法设为private,并复制成一个模块方法 # 这方法1.8有没有呢……………… module_function def make_name NAME_LIST.collect(&:sample).join end end # 这样一来,事件脚本里就可以省略“ZhengQi.”了 # 参考Ruby的Math模块 class Game_Interpreter include ZhengQi end
# class...NAME_LIST = [ ["疾风","烈焰","狂雷","飞天","旋风"], ["升龙","裂空","惊涛","三连","圣灵"], ["斩","击","拳","刺","爪"]]def make_name NAME_LIST.collect(&:sample).joinend
# class... NAME_LIST = [ ["疾风","烈焰","狂雷","飞天","旋风"], ["升龙","裂空","惊涛","三连","圣灵"], ["斩","击","拳","刺","爪"] ] def make_name NAME_LIST.collect(&:sample).join end
Lv2.观梦者
Lv4.逐梦者
bluer公主殿下
本版积分规则 发表回复
这里的今天,有我过往努力的见证~
献给最先抵达这片土地的你。参加预注册的用户即可获得。
折叠内容标题(非必须)
折叠内容
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-11-28 14:19
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.