查看: 2008|回复: 3

帮忙翻译下这段脚本

  [复制链接]
头像被屏蔽
梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-3-8
回帖
32
发表于 2008-5-11 18:14:02 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽

酱油的

梦石
0
星屑
1840
在线时间
2161 小时
注册时间
2007-12-22
回帖
3216

贵宾

发表于 2008-5-11 18:22:08 | 显示全部楼层
這下倒是提醒我忘記收錄 split 的用法了==|||
split 是分切字符轉換爲數組的方法
!=    是 == 的反義詞
××× ? ××× : ××× 的意思等於
if ××× then ××× else ××× end
看下面兩個例子:
a = "1@2@3@4@"
p a.split(/@/)

module RPG
class Skill
  def description
    description = @description.split(/@/)[0]
    if description == nil
      return ''
    else
      return description
    end
  end
  def desc
    desc = @description.split(/@/)[1]
    if desc == nil
      return "普通技能"
    else
      return desc
    end
  end
end
end

系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
不做頭像做簽名,看我囧冏有神(多謝山人有情提供 )
回复

使用道具 举报

头像被屏蔽
梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-3-8
回帖
32
 楼主| 发表于 2008-5-11 18:24:31 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复

使用道具 举报

酱油的

梦石
0
星屑
1840
在线时间
2161 小时
注册时间
2007-12-22
回帖
3216

贵宾

发表于 2008-5-11 18:33:59 | 显示全部楼层
在ruby interperter 的 class String 當中定義的。
RGSS 當然找不到。
補上幾個官方資料,剛好找到的:

   " now's  the time".split        #=> ["now's", "the", "time"]
   " now's  the time".split(' ')   #=> ["now's", "the", "time"]
   " now's  the time".split(/ /)   #=> ["", "now's", "", "the", "time"]
   "1, 2.34,56, 7".split(%r{,\s*}) #=> ["1", "2.34", "56", "7"]
   "hello".split(//)               #=> ["h", "e", "l", "l", "o"]
   "hello".split(//, 3)            #=> ["h", "e", "llo"]
   "hi mom".split(%r{\s*})         #=> ["h", "i", "m", "o", "m"]

   "mellow yellow".split("ello")   #=> ["m", "w y", "w"]
   "1,2,,3,4,,".split(',')         #=> ["1", "2", "", "3", "4"]
   "1,2,,3,4,,".split(',', 4)      #=> ["1", "2", "", "3,4,,"]
   "1,2,,3,4,,".split(',', -4)     #=> ["1", "2", "", "3", "4", "", ""]
不做頭像做簽名,看我囧冏有神(多謝山人有情提供 )
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部