制作攻略必备——宝箱导出工具
RUBY 代码#==============================================================================
# ■ Treasure_Export
#------------------------------------------------------------------------------
# 宝箱导出工具 by SailCat
# 该程序能够导出工程中的全部宝箱,包括剧情获得道具,方便查错。
# 使用说明:
# 插入本脚本到Game_Temp(注意:不是Main)之前后执行就可以,你也可以手工做:
# treasure = Treasure_Export.new
# treasure.export_treasure(1)# 导出第1张地图的宝箱
# treasure.export_all_treasures # 导出所有地图的宝箱
# 导出的对话写在工程目录下的TreasureScript.txt文件里
# 注释掉第109行及以下的语句可以屏蔽这个功能,正常测试游戏
#==============================================================================
class Treasure_Export
#--------------------------------------------------------------------------
# ● 初期化
#--------------------------------------------------------------------------
def initialize
# 删除前次导出的文件
ifFileTest.exist?("TreasureScript.txt")
File.delete("TreasureScript.txt")
end
@item_data = load_data("Data/Items.rxdata")
@weapon_data = load_data("Data/Weapons.rxdata")
@armor_data = load_data("Data/Armors.rxdata")
@map_infos = load_data("Data/MapInfos.rxdata")
end
#--------------------------------------------------------------------------
# ● 执行导出宝箱
# map_id: 地图ID
#--------------------------------------------------------------------------
def export_treasure(map_id)
File.open("TreasureScript.txt", "a")do |f|
map_name = sprintf("Data/Map%03d.rxdata", map_id)
ifFileTest.exist?(map_name)
# 载入当前地图
map = load_data(map_name)
m = false
# 循环地图中所有事件
for i in1..999
event = map.events
if event != nil
t = false
# 循环事件的每一页
event.pages.eachdo |page|
# 如果指令不为空
if page.list.length > 0
# 循环页的所有指令
page.list.eachdo |command|
# 检查宝箱指令
info = ""
case command.code
when125# 增减金钱
if command.parameters == 0
info = sprintf("金钱: %s%d", command.parameters == 1 ?
"变量" : "", command.parameters)
end
when126# 增减道具
if command.parameters == 0
info = sprintf("道具: %s x %s%d", @item_data].name,
command.parameters == 1 ? "变量" : "", command.parameters)
end
when127# 增减武器
if command.parameters == 0
info = sprintf("武器: %s x %s%d", @weapon_data].name,
command.parameters == 1 ? "变量" : "", command.parameters)
end
when128# 增减防具
if command.parameters == 0
info = sprintf("防具: %s x %s%d", @armor_data].name,
command.parameters == 1 ? "变量" : "", command.parameters)
end
end
if info != ""
# 输出事件提示字样
if !m
f.write("-----------------------------------------------------\n")
f.write(sprintf(" ■ Map: %d (%s)\n", map_id, @map_infos.name))
f.write("-----------------------------------------------------\n")
m = true
end
if !t
f.write(sprintf(" □ 坐标: (%03d, %03d); ", event.x, event.y))
t = true
else
f.write(" ")
end
# 输出宝箱
f.write(info)
f.write("\n")
end
end
end
end
end
end
end
end
end
#--------------------------------------------------------------------------
# ● 批量导出宝箱
#--------------------------------------------------------------------------
def export_all_treasures
for map_id in1..999
export_treasure(map_id)
end
end
end
t=Treasure_Export.new
t.export_all_treasures
exit
导出效果展示:
本帖来自P1论坛作者Zhangjiaxing1,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=374635若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]