#-------------------------------------------------------------------------------
#
# ▼ 读取注释栏指定字段
#
# 采用沉影不器的 ReadNote -fscript 2.02.1001 脚本,请与read_notes区别
#
# 【例】在vx数据库比如1号物品的备注栏里写: 耐久度 = 10
# 读取时使用: p $data_items[1].read_note('耐久度')
#
# 几点注意:
# ① 支持汉字,英文忽略大小写
# ② 等号右边遵循ruby语法格式,例如:
# test1 = 1 #=> 1
# test2 = "a" #=> "a"
# test3 = true #=> true
# test4 = [1,2,3] #=> [1,2,3]
# test5 = {"orz"=>1} #=> {"orz"=>1}
# ③ 等号忽略空格,以下均正确:
# test = nil; test= nil; test =nil; test=nil
#----------------------------------------------------------------------------
module RPG
module ReadNote
def self.read(str, section, mismatch = nil)
str.each_line do |line|
## 不希望忽略大小写,则删掉下一行最后一个i
eval("#{line}; return #{section}") if line =~ /^\s*#{section}\s*=/i
end
return mismatch
end
end
#-------------------------------------------------------------------------
# ○ 读取rmvx备注栏指定字段
# section : 字段名
# mismatch : 未匹配时的返回值
#-------------------------------------------------------------------------
class BaseItem
def read_note(section, mismatch = nil)
ReadNote.read(self.note, section, mismatch)
end
end
class Enemy
def read_note(section, mismatch = nil)
ReadNote.read(self.note, section, mismatch)
end
end
class State
def read_note(section, mismatch = nil)
ReadNote.read(self.note, section, mismatch)
end
end
end
#-------------------------------------------------------------------------------
#
# ▼ 读取注释栏指定字段
#
# 采用沉影不器的 ReadNote -fscript 2.02.1001 脚本,请与read_notes区别
#
# 【例】在vx数据库比如1号物品的备注栏里写: 耐久度 = 10
# 读取时使用: p $data_items[1].read_note('耐久度')
#
# 几点注意:
# ① 支持汉字,英文忽略大小写
# ② 等号右边遵循ruby语法格式,例如:
# test1 = 1 #=> 1
# test2 = "a" #=> "a"
# test3 = true #=> true
# test4 = [1,2,3] #=> [1,2,3]
# test5 = {"orz"=>1} #=> {"orz"=>1}
# ③ 等号忽略空格,以下均正确:
# test = nil; test= nil; test =nil; test=nil
#----------------------------------------------------------------------------
module RPG
module ReadNote
def self.read(str, section, mismatch = nil)
str.each_line do |line|
## 不希望忽略大小写,则删掉下一行最后一个i
eval("#{line}; return #{section}") if line =~ /^\s*#{section}\s*=/i
end
return mismatch
end
end
#-------------------------------------------------------------------------
# ○ 读取rmvx备注栏指定字段
# section : 字段名
# mismatch : 未匹配时的返回值
#-------------------------------------------------------------------------
class BaseItem
def read_note(section, mismatch = nil)
ReadNote.read(self.note, section, mismatch)
end
end
class Enemy
def read_note(section, mismatch = nil)
ReadNote.read(self.note, section, mismatch)
end
end
class State
def read_note(section, mismatch = nil)
ReadNote.read(self.note, section, mismatch)
end
end
end