查看: 1477|回复: 0

输出部分脚本

[复制链接]

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-6-14 20:37:28 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 taroxd 于 2014-7-28 12:36 编辑

需要用到这个功能的人自然知道怎么用

[pre lang="ruby" line="1"]

#==============================================================================
# ★ 输出脚本
#==============================================================================

path = 'scripts'
ext  = '.rb'

output = lambda do
  Dir.mkdir(path) unless File.directory?(path)
  $RGSS_SCRIPTS.each_with_index do |(_, tag, _, contents), i|
    next unless tag.start_with?('★')..tag.start_with?('☆')
    next if contents.force_encoding("utf-8").empty?
    filename = tag.delete('/:*?"<>|\\')
    if filename.empty?
      msgbox "Warning: script #{i} with an invalid tag"
    else
      File.open("#{path}/#{filename}#{ext}", "wb") {|f| f << contents }
    end
  end
  msgbox 'Scripts output successfully.'
  exit
end

#~ output.call if $TEST
[/pre]

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

在本发帖返回顶部