Project1

标题: 帮忙翻译下这段脚本 [打印本页]

作者: havealook2    时间: 2008-5-11 18:14
提示: 作者被禁止或删除 内容自动屏蔽
作者: 禾西    时间: 2008-5-11 18:22
這下倒是提醒我忘記收錄 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
[LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: havealook2    时间: 2008-5-11 18:24
提示: 作者被禁止或删除 内容自动屏蔽
作者: 禾西    时间: 2008-5-11 18:33
在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", "", ""]





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1