-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update export.lua #2346
Open
lili-ffxi
wants to merge
4
commits into
dev
Choose a base branch
from
lili-gs-export-update
base: dev
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update export.lua #2346
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,11 @@ | |
--(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
require('logger') | ||
function export_set(options) | ||
local item_list = T{} | ||
local targinv,all_items,minify,all_sets,use_job_in_filename,use_subjob_in_filename,overwrite_existing,named_file | ||
local targinv,all_items,wearable,all_sets,noaugments,onlyaugmented,minify,clipboard | ||
local use_job_in_filename,use_subjob_in_filename,overwrite_existing,named_file | ||
if #options > 0 then | ||
for _,v in ipairs(options) do | ||
if S{'inventory','inv','i'}:contains(v:lower()) then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
local option = v:lower() |
||
|
@@ -35,14 +37,22 @@ function export_set(options) | |
all_items = true | ||
elseif v:lower() == 'wearable' then | ||
wearable = true | ||
elseif S{'mini'}:contains(v:lower()) then | ||
minify = true | ||
elseif S{'sets','set','s'}:contains(v:lower()) then | ||
all_sets = true | ||
if not user_env or not user_env.sets then | ||
msg.addon_msg(123,'Cannot export the sets table of the current file because there is no file loaded.') | ||
return | ||
end | ||
elseif S{'noaugments','noaugs'}:contains(v:lower()) then | ||
noaugments = true | ||
onlyaugmented = nil | ||
elseif S{'onlyaugmented','onlyaugs'}:contains(v:lower()) then | ||
onlyaugmented = true | ||
noaugments = nil | ||
elseif S{'mini','minify'}:contains(v:lower()) then | ||
minify = true | ||
elseif S{'copy','clipboard'}:contains(v:lower()) then | ||
clipboard = true | ||
elseif v:lower() == 'mainjob' then | ||
use_job_in_filename = true | ||
elseif v:lower() == 'mainsubjob' then | ||
|
@@ -72,26 +82,32 @@ function export_set(options) | |
buildmsg = buildmsg..'your currently equipped gear' | ||
end | ||
|
||
buildmsg = buildmsg..' as a lua file.' | ||
if clipboard then | ||
buildmsg = buildmsg..' to clipboard.' | ||
else | ||
buildmsg = buildmsg..' as a lua file.' | ||
|
||
if use_job_in_filename then | ||
buildmsg = buildmsg..' (Naming format: Character_JOB)' | ||
elseif use_subjob_in_filename then | ||
buildmsg = buildmsg..' (Naming format: Character_JOB_SUB)' | ||
elseif named_file then | ||
buildmsg = buildmsg..' (Named: Character_'..filename..')' | ||
if use_job_in_filename then | ||
buildmsg = buildmsg..' (Naming format: Character_JOB)' | ||
elseif use_subjob_in_filename then | ||
buildmsg = buildmsg..' (Naming format: Character_JOB_SUB)' | ||
elseif named_file then | ||
buildmsg = buildmsg..' (Named: Character_'..filename..')' | ||
end | ||
|
||
if overwrite_existing then | ||
buildmsg = buildmsg..' Will overwrite existing files with same name.' | ||
end | ||
end | ||
|
||
if overwrite_existing then | ||
buildmsg = buildmsg..' Will overwrite existing files with same name.' | ||
if noaugments then | ||
buildmsg = buildmsg..' noaugments.' | ||
elseif onlyaugmented then | ||
buildmsg = buildmsg..' onlyaugmented.' | ||
end | ||
|
||
msg.addon_msg(123,buildmsg) | ||
|
||
if not windower.dir_exists(windower.addon_path..'data/export') then | ||
windower.create_dir(windower.addon_path..'data/export') | ||
end | ||
|
||
if all_items then | ||
for i = 0, #res.bags do | ||
item_list:extend(get_item_list(items[res.bags[i].english:gsub(' ', ''):lower()])) | ||
|
@@ -158,56 +174,49 @@ function export_set(options) | |
end | ||
end | ||
|
||
local output = 'sets.exported={\n' | ||
|
||
if not windower.dir_exists(windower.addon_path..'data/export') then | ||
windower.create_dir(windower.addon_path..'data/export') | ||
local newline = minify and '' or '\n' | ||
for i,v in ipairs(item_list) do | ||
if v.name ~= empty then | ||
if v.augments and not noaugments then | ||
--Advanced set table | ||
output = output .. ' '..v.slot..'={ name="'..v.name..'", augments={'..v.augments..'}},'..newline | ||
elseif not onlyaugmented then | ||
output = output .. ' '..v.slot..'="'..v.name..'",'..newline | ||
end | ||
end | ||
end | ||
output = output .. '}' | ||
|
||
local path = windower.addon_path..'data/export/'..player.name | ||
|
||
if use_job_in_filename then | ||
path = path..'_'..windower.ffxi.get_player().main_job | ||
elseif use_subjob_in_filename then | ||
path = path..'_'..windower.ffxi.get_player().main_job..'_'..windower.ffxi.get_player().sub_job | ||
elseif named_file then | ||
path = path..'_'..filename | ||
if clipboard then | ||
windower.copy_to_clipboard(output) | ||
else | ||
path = path..os.date(' %Y-%m-%d %H-%M-%S') | ||
end | ||
|
||
if not windower.dir_exists(windower.addon_path..'data/export') then | ||
windower.create_dir(windower.addon_path..'data/export') | ||
end | ||
|
||
if (not overwrite_existing) and windower.file_exists(path..'.lua') then | ||
path = path..' '..os.clock() | ||
end | ||
local path = windower.addon_path..'data/export/'..player.name | ||
|
||
local f = io.open(path..'.lua','w+') | ||
if minify then | ||
f:write('sets.exported={\n') | ||
for i,v in ipairs(item_list) do | ||
if v.name ~= empty then | ||
if v.augments then | ||
--Advanced set table | ||
f:write(v.slot..'={ name="'..v.name..'", augments={'..v.augments..'}},') | ||
else | ||
f:write(v.slot..'="'..v.name..'",') | ||
end | ||
end | ||
if use_job_in_filename then | ||
path = path..'_'..windower.ffxi.get_player().main_job | ||
elseif use_subjob_in_filename then | ||
path = path..'_'..windower.ffxi.get_player().main_job..'_'..windower.ffxi.get_player().sub_job | ||
elseif named_file then | ||
path = path..'_'..filename | ||
else | ||
path = path..os.date(' %Y-%m-%d %H-%M-%S') | ||
end | ||
f:write('\n}') | ||
else | ||
f:write('sets.exported={\n') | ||
for i,v in ipairs(item_list) do | ||
if v.name ~= empty then | ||
if v.augments then | ||
--Advanced set table | ||
f:write(' '..v.slot..'={ name="'..v.name..'", augments={'..v.augments..'}},\n') | ||
else | ||
f:write(' '..v.slot..'="'..v.name..'",\n') | ||
end | ||
end | ||
|
||
if (not overwrite_existing) and windower.file_exists(path..'.lua') then | ||
path = path..' '..os.clock() | ||
end | ||
f:write('}') | ||
|
||
local f = io.open(path..'.lua','w+') | ||
f:write(output) | ||
f:close() | ||
end | ||
f:close() | ||
end | ||
|
||
function unpack_names(ret_tab,up,tab_level,unpacked_table,exported) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is not your doing, but I would put these all on separate lines and initialize them with default values (
false
for most of them).