| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 2 |
| 经验 | |
| 最后登录 | 2025-10-19 |
| 在线时间 | 454 小时 |
- 梦石
- 0
- 星屑
- 166
- 在线时间
- 454 小时
- 注册时间
- 2015-2-25
- 回帖
- 358
|
发表于 2015-4-15 15:47:19
|
显示全部楼层
本帖最后由 howhow1314 于 2015-4-15 15:50 编辑
推薦你用兩個腳本...
第一個:https://rpg.blue/forum.php?mod=viewthread&tid=331630
第二個...忘了在哪找來的,非常非常非常非常好用的腳本
[pre lang="ruby"]#-------------------------------------------------------------------------------
#
# ▼ 读取注释栏指定字段
#
# 采用沉影不器的 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[/pre]
有了這2個腳本,自己寫個抓怪什麼的太簡單了有沒有
|
|