| 赞 | 66 |
| VIP | |
| 好人卡 | |
| 积分 | 19 |
| 经验 | |
| 最后登录 | 2026-7-23 |
| 在线时间 | 1555 小时 |
- 梦石
- 0
- 星屑
- 1907
- 在线时间
- 1555 小时
- 注册时间
- 2013-4-13
- 回帖
- 783
|
楼主 |
发表于 2013-4-20 19:16:43
|
显示全部楼层
6rp 发表于 2013-4-20 17:37 
message就是这样使用的:
$game_message.add('hello')[/pre]
感谢已经成功读取文件了
突然发现可以用Excel 批量转换txt 效率提高一大截
唯一遗憾就是不知道如何在类内部使用
不过暂且用类方法解决了
- $dialog = Array.new(72,Array.new)
- #=============================================================================
- class Dialog
- attr_accessor :index
- attr_accessor :label
- attr_accessor :label_target
- attr_accessor :condition
- attr_accessor :option
- attr_accessor :picid
- attr_accessor :content
- @@interpret = [Hash.new]
- ##============================================================================
- ##============================================================================
- def self.intercreate(i)
- @@interpret[i] = Hash.new
- end
- def self.intercrease(i,l,li)
- @@interpret[i][l] = li
- end
- def self.interpret(i)
- return @@interpret[i]
- end
- def self.setup
- @@interpret = [Hash.new]
- load('book.etc')
- end
- def initialize(i,l,c,o,p,con,lt)
- @index = i
- @label = l
- @label_target = lt
- @condition = c
- @option = o
- @picid = p
- p @content = con
- end
- end
复制代码
转换成txt以后 Excel 会自动给所有带括号的部分添加双引号,还会插入大量tab,用查找替换一次性删除勉强算是弄掉了- def run(i,l,c,o,p,con,lt)
- $dialog[i].push Dialog.new(i,l,c,o,p,con,lt)
- $dialog[i].compact!
- li = $dialog[i].size - 1
- p Dialog.interpret(i)
- Dialog.intercreate(i) if Dialog.interpret(i) == nil
- Dialog.intercrease(i,l,li)
- end
- i = 1
- l = ' 2 '
- c = ' 3 '
- o = ' 4 '
- con = ' 5 '
- lt = ' 6 '
- run(i,l,c,o,p,con,lt)
复制代码
大概就生成这么个东西
测试结果还算满意,但是不能在类内使用还是问题,这些变量难道都被当成main函数的局部变量了么?
|
|