作废
name1 = %w[大 魔 金 小 龙 凤 花 云 仇 司马]
name2 = %w[恨 轩辕 萨 刚 花形 缺 笑谈 辟 鱼 雷]
name3 = %w[天 生 鲁 罗刹 成 吉 宇文 甘 泳 灵]
a = name1[rand(10)]
b = name2[rand(10)]
c = name3[rand(10)]
name1 = ["大","魔","金","小","龙","凤","花","云","仇","司马"]
name2 = ["恨","轩辕","萨","刚","花形","缺","笑谈","辟","鱼","雷"]
name3 = ["天","生","鲁","罗刹","成","吉","宇文","甘","泳","灵"]
a = name1[rand(10)]
b = name2[rand(10)]
c = name3[rand(10)]
以下引用禾西于2008-5-27 3:16:10的发言:
隨機生成人物的實例 XDDDD 創意不錯。不過有些意見
話說我很懷疑這段的用途是甚麽....怎麼每個分歧都是一樣的==a
cn = rand(3)
cn_2 = rand(6)
case cn_2
when 0
if $性别.include?("男")
$data_actors[id].name = a+c+b
end
if $性别.include?("女")
$data_actors[id].name = a1+c1+b1
end
when 1
if $性别.include?("男")
$data_actors[id].name = a+b+c
end
if $性别.include?("女")
$data_actors[id].name = a1+b1+c1
end
when 2
if $性别.include?("男")
$data_actors[id].name = b+a+c
end
if $性别.include?("女")
$data_actors[id].name = b1+a1+c1
end
when 3
if $性别.include?("男")
$data_actors[id].name = b+c+a
end
if $性别.include?("女")
$data_actors[id].name = b1+c1+a1
end
when 4
if $性别.include?("男")
$data_actors[id].name = c+a+b
end
if $性别.include?("女")
$data_actors[id].name = c1+a1+b1
end
when 5
if $性别.include?("男")
$data_actors[id].name = c+b+a
end
if $性别.include?("女")
$data_actors[id].name = c1+b1+a1
end
end
另外推薦你使用這種代碼:
name1 = %w[大 魔 金 小 龙 凤 花 云 仇 司马]
name2 = %w[恨 轩辕 萨 刚 花形 缺 笑谈 辟 鱼 雷]
name3 = %w[天 生 鲁 罗刹 成 吉 宇文 甘 泳 灵]
a = name1[rand(10)]
b = name2[rand(10)]
c = name3[rand(10)]
or
name1 = ["大","魔","金","小","龙","凤","花","云","仇","司马"]
name2 = ["恨","轩辕","萨","刚","花形","缺","笑谈","辟","鱼","雷"]
name3 = ["天","生","鲁","罗刹","成","吉","宇文","甘","泳","灵"]
a = name1[rand(10)]
b = name2[rand(10)]
c = name3[rand(10)]
隨便挑一種學(茶)
注釋很少(幾乎沒有),雖然禾西看得懂,但是用起來不是很方便。代碼不是很漂亮,應該要學習一下使用數組與Hash表 XD。
[本贴由作者于 2008-5-27 3:30:42 最后编辑]
以下引用snstar2006于2008-5-27 6:02:41的发言:
也許LZ可以參考一下我的道具名稱產生器
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |