From 755b4fa3840c9dd825e09623f1f63b57661a5a92 Mon Sep 17 00:00:00 2001 From: Mason11987 Date: Mon, 12 Oct 2015 05:15:32 -0400 Subject: [PATCH 1/4] Fixing assume identities since it causes a crash. --- scripts/exportlegends.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/exportlegends.lua b/scripts/exportlegends.lua index ac5686cb6..59e73a3e9 100644 --- a/scripts/exportlegends.lua +++ b/scripts/exportlegends.lua @@ -397,14 +397,16 @@ function export_more_legends_xml() --io.write ("\t\t".."<"..k.."_item_mat_index"..">"..tostring(event.props.item.mat_index).."".."\n") io.write ("\t\t".."<"..k.."_pile_type"..">"..tostring(event.props.pile_type).."".."\n") elseif event:getType() == df.history_event_type.ASSUME_IDENTITY and k == "identity" then - if (df.global.world.identities.all[v].histfig_id == -1) then - local thisIdentity = df.global.world.identities.all[v] - io.write ("\t\t"..""..thisIdentity.name.first_name.."".."\n") - io.write ("\t\t"..""..(df.global.world.raws.creatures.all[thisIdentity.race].creature_id):lower().."".."\n") - io.write ("\t\t"..""..(df.global.world.raws.creatures.all[thisIdentity.race].caste[thisIdentity.caste].caste_id):lower().."".."\n") - else - io.write ("\t\t"..""..df.global.world.identities.all[v].histfig_id.."".."\n") - end + if (table.contains(df.global.world.identities.all,v)) then + if (df.global.world.identities.all[v].histfig_id == -1) then + local thisIdentity = df.global.world.identities.all[v] + io.write ("\t\t"..""..thisIdentity.name.first_name.."".."\n") + io.write ("\t\t"..""..(df.global.world.raws.creatures.all[thisIdentity.race].creature_id):lower().."".."\n") + io.write ("\t\t"..""..(df.global.world.raws.creatures.all[thisIdentity.race].caste[thisIdentity.caste].caste_id):lower().."".."\n") + else + io.write ("\t\t"..""..df.global.world.identities.all[v].histfig_id.."".."\n") + end + end elseif event:getType() == df.history_event_type.MASTERPIECE_CREATED_ARCH_CONSTRUCT and k == "building_type" then io.write ("\t\t"..""..df.building_type[v]:lower().."".."\n") elseif event:getType() == df.history_event_type.MASTERPIECE_CREATED_ARCH_CONSTRUCT and k == "building_subtype" then From 2993edaf7306b2729fdaf6ce2a50cd815abe6b32 Mon Sep 17 00:00:00 2001 From: Mason11987 Date: Mon, 12 Oct 2015 05:21:16 -0400 Subject: [PATCH 2/4] spacing --- scripts/exportlegends.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/exportlegends.lua b/scripts/exportlegends.lua index 59e73a3e9..ba39ea8c4 100644 --- a/scripts/exportlegends.lua +++ b/scripts/exportlegends.lua @@ -397,16 +397,16 @@ function export_more_legends_xml() --io.write ("\t\t".."<"..k.."_item_mat_index"..">"..tostring(event.props.item.mat_index).."".."\n") io.write ("\t\t".."<"..k.."_pile_type"..">"..tostring(event.props.pile_type).."".."\n") elseif event:getType() == df.history_event_type.ASSUME_IDENTITY and k == "identity" then - if (table.contains(df.global.world.identities.all,v)) then - if (df.global.world.identities.all[v].histfig_id == -1) then - local thisIdentity = df.global.world.identities.all[v] - io.write ("\t\t"..""..thisIdentity.name.first_name.."".."\n") - io.write ("\t\t"..""..(df.global.world.raws.creatures.all[thisIdentity.race].creature_id):lower().."".."\n") - io.write ("\t\t"..""..(df.global.world.raws.creatures.all[thisIdentity.race].caste[thisIdentity.caste].caste_id):lower().."".."\n") - else - io.write ("\t\t"..""..df.global.world.identities.all[v].histfig_id.."".."\n") - end - end + if (table.contains(df.global.world.identities.all,v)) then + if (df.global.world.identities.all[v].histfig_id == -1) then + local thisIdentity = df.global.world.identities.all[v] + io.write ("\t\t"..""..thisIdentity.name.first_name.."".."\n") + io.write ("\t\t"..""..(df.global.world.raws.creatures.all[thisIdentity.race].creature_id):lower().."".."\n") + io.write ("\t\t"..""..(df.global.world.raws.creatures.all[thisIdentity.race].caste[thisIdentity.caste].caste_id):lower().."".."\n") + else + io.write ("\t\t"..""..df.global.world.identities.all[v].histfig_id.."".."\n") + end + end elseif event:getType() == df.history_event_type.MASTERPIECE_CREATED_ARCH_CONSTRUCT and k == "building_type" then io.write ("\t\t"..""..df.building_type[v]:lower().."".."\n") elseif event:getType() == df.history_event_type.MASTERPIECE_CREATED_ARCH_CONSTRUCT and k == "building_subtype" then From db3a1024e1351e5ff39776e64f9397e9dc751c8b Mon Sep 17 00:00:00 2001 From: Mason11987 Date: Mon, 12 Oct 2015 05:59:51 -0400 Subject: [PATCH 3/4] Fixes to allow open-legends to allow export as well. --- scripts/exportlegends.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/exportlegends.lua b/scripts/exportlegends.lua index ba39ea8c4..ad11d431c 100644 --- a/scripts/exportlegends.lua +++ b/scripts/exportlegends.lua @@ -525,10 +525,12 @@ function export_legends_info() export_more_legends_xml() end --- presses 'd' for detailed maps function wait_for_legends_vs() local vs = dfhack.gui.getCurViewscreen() if i <= #MAPS then + if df.viewscreen_legendsst:is_instance(vs.parent) then + vs = vs.parent + end if df.viewscreen_legendsst:is_instance(vs) then gui.simulateInput(vs, 'LEGENDS_EXPORT_DETAILED_MAP') dfhack.timeout(10,'frames',wait_for_export_maps_vs) @@ -555,6 +557,9 @@ end -- export site maps function export_site_maps() local vs = dfhack.gui.getCurViewscreen() + if ((dfhack.gui.getCurFocus() ~= "legends" ) and (not table.contains(vs, "main_cursor"))) then -- Using open-legends + vs = vs.parent + end print(' Exporting: All possible site maps') vs.main_cursor = 1 gui.simulateInput(vs, 'SELECT') @@ -567,7 +572,6 @@ end -- main() if dfhack.gui.getCurFocus() == "legends" or dfhack.gui.getCurFocus() == "dfhack/lua/legends" then - -- either native legends mode, or using the open-legends.lua script if args[1] == "all" then export_legends_info() export_site_maps() From dea78d062728f5dfbdc32795bf559142733a26da Mon Sep 17 00:00:00 2001 From: Mason11987 Date: Mon, 12 Oct 2015 06:02:51 -0400 Subject: [PATCH 4/4] Put mistakenly removed comments back --- scripts/exportlegends.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/exportlegends.lua b/scripts/exportlegends.lua index ad11d431c..721d793f3 100644 --- a/scripts/exportlegends.lua +++ b/scripts/exportlegends.lua @@ -525,6 +525,7 @@ function export_legends_info() export_more_legends_xml() end +--- presses 'd' for detailed maps function wait_for_legends_vs() local vs = dfhack.gui.getCurViewscreen() if i <= #MAPS then @@ -572,6 +573,7 @@ end -- main() if dfhack.gui.getCurFocus() == "legends" or dfhack.gui.getCurFocus() == "dfhack/lua/legends" then + -- either native legends mode, or using the open-legends.lua script if args[1] == "all" then export_legends_info() export_site_maps()