diff --git a/aard_inventory.changelog b/aard_inventory.changelog index 738dff0..875c65a 100644 --- a/aard_inventory.changelog +++ b/aard_inventory.changelog @@ -2,6 +2,13 @@ dbot.changelog = {} +dbot.changelog[2.0010] = +{ + { change = drlDbotChangeLogTypeNew, + desc = Added "dinv priority copy [name]" and "dinv priority paste [name]" + } +} + dbot.changelog[2.0009] = { { change = drlDbotChangeLogTypeNew, diff --git a/aard_inventory.xml b/aard_inventory.xml index 25db5f2..14e504a 100644 --- a/aard_inventory.xml +++ b/aard_inventory.xml @@ -87,7 +87,7 @@ dbot.version : Module to track version and changelog information and update the save_state="y" date_written="2017-08-12 08:45:15" requires="4.98" - version="2.0009" + version="2.0010" > dinv snapshot [create | delete | list | display | wear] - dinv priority [list | display | create | clone | delete | edit | compare] + dinv priority [list | display | create | clone | delete | edit | copy | paste | compare] Equipment analysis dinv analyze [list | create | delete | display] @@ -536,7 +536,7 @@ Feature Wishlist @w") end -- inv.cli.priority.usage @@ -2584,7 +2590,22 @@ Examples: mode on a large priority, you may need to resize your edit window to see everything. "@Gdinv priority edit mage full@W" - 8) Compare the stat differences at all levels for the equipment sets generated by two different + 8) Use an external editor to modify a priority. You can copy the priority data to the system + clipboard to make it easy to transfer the priority to your own editor. + "@Gdinv priority copy psi-melee@W" + + 9) Paste priority data from the system clipboard and use that data to either create a new + priority (if it doesn't exist yet) or update an existing priority. This is convenient if you + used an external editor to modify the priority data and you want to import that data back into + the plugin. + "@Gdinv priority paste myThief@W" + + 10) Copy/paste a priority to make a duplicate. Yes, this is essentially the "@Cclone@W" mode, + but it shows off what you can do with "@Ccopy@W" and "@Cpaste@W". + "@Gdinv priority copy mage@W" + "@Gdinv priority paste myMage@W" + + 11) Compare the stat differences at all levels for the equipment sets generated by two different priorities. This will generate a big report that I didn't include here because this helpfile is already enormous :) If you have not already performed a full analysis of both priorities you will be prompted to do so before the comparison can execute. The output shown below is @@ -10259,8 +10280,9 @@ end -- inv.cache.clearOld -- inv.priority.display(priorityName, endTag) -- -- inv.priority.edit(priorityName, useAllFields, isQuiet, endTag) --- inv.priority.split(priorityName, level, endTag) --- inv.priority.join(priorityName, level, endTag) +-- inv.priority.update(priorityName, priorityString, isQuiet) +-- inv.priority.copy(priorityName, endTag) +-- inv.priority.paste(priorityName, endTag) -- -- inv.priority.compare(priorityName1, priorityName2, endTag) -- @@ -10521,7 +10543,7 @@ end -- inv.priority.display function inv.priority.edit(priorityName, useAllFields, isQuiet, endTag) local retval = DRL_RET_SUCCESS - local priorityEntry, priorityString = nil, "" + local priorityString = "" if (priorityName == nil) or (priorityName == "") then dbot.warn("inv.priority.edit: priority name is missing!") @@ -10573,22 +10595,7 @@ The first column lists the names of each available priority field. Subsequent c break else - priorityEntry, retval = inv.priority.stringToTable(priorityString) - if (retval ~= DRL_RET_SUCCESS) then - dbot.debug("inv.priority.edit: Failed to convert priority string into priority: " .. - dbot.retval.getString(retval)) - else - inv.priority.table[priorityName] = priorityEntry - if (not isQuiet) then - dbot.info("Updated priority \"@C" .. priorityName .. "@W\"") - end -- if - inv.priority.save() - - -- Invalidate any previous equipment set analyzis based on this priority - inv.set.table[priorityName] = nil - inv.set.save() - - end -- if + retval = inv.priority.update(priorityName, priorityString, isQuiet) end -- if until (retval == DRL_RET_SUCCESS) @@ -10596,22 +10603,97 @@ The first column lists the names of each available priority field. Subsequent c end -- inv.priority.edit -function inv.priority.split(priorityName, level, endTag) - local retval = DRL_RET_SUCCESS +function inv.priority.update(priorityName, priorityString, isQuiet) + + if (priorityName == nil) or (priorityName == "") then + dbot.warn("inv.priority.update: Missing priority name parameter") + return DRL_RET_INVALID_PARAM + end -- if + + if (priorityString == nil) or (priorityString == "") then + dbot.warn("inv.priority.update: Missing priority string parameter") + return DRL_RET_INVALID_PARAM + end -- if + + local priorityEntry, retval = inv.priority.stringToTable(priorityString) + if (retval ~= DRL_RET_SUCCESS) then + dbot.debug("inv.priority.update: Failed to convert priority string into priority: " .. + dbot.retval.getString(retval)) + else + inv.priority.table[priorityName] = priorityEntry + if (not isQuiet) then + dbot.info("Updated priority \"@C" .. priorityName .. "@W\"") + end -- if + inv.priority.save() + + -- Invalidate any previous equipment set analyzis based on this priority + inv.set.table[priorityName] = nil + inv.set.save() + + end -- if - dbot.note("FIXME: split -- do we want/need this?") + return retval +end -- inv.priority.update + + +function inv.priority.copy(priorityName, endTag) + + if (priorityName == nil) or (priorityName == "") then + dbot.warn("inv.priority.copy: Missing priority name parameter") + return inv.tags.stop(invTagsPriority, endTag, DRL_RET_INVALID_PARAM) + end -- if + + if (inv.priority.table[priorityName] == nil) then + dbot.warn("inv.priority.copy: priority \"@C" .. priorityName .. "@W\" does not exist") + return inv.tags.stop(invTagsPriority, endTag, DRL_RET_MISSING_ENTRY) + end -- if + + -- Get a string representation of the priority we want to copy + local priorityString, retval = inv.priority.tableToString(inv.priority.table[priorityName], + true, false, true) + if (retval ~= DRL_RET_SUCCESS) then + dbot.warn("inv.priority.copy: Failed to get string representation of priority \"@C" .. + priorityName .. "@W\": " .. dbot.retval.getString(retval)) + else + SetClipboard(priorityString) + dbot.info("Copied priority \"@C" .. priorityName .. "@W\" to clipboard") + end -- if return inv.tags.stop(invTagsPriority, endTag, retval) -end -- inv.priority.split +end -- inv.priority.copy -function inv.priority.join(priorityName, level, endTag) +function inv.priority.paste(priorityName, endTag) local retval = DRL_RET_SUCCESS + local operation - dbot.note("FIXME: join -- do we want/need this?") + if (priorityName == nil) or (priorityName == "") then + dbot.warn("inv.priority.paste: Missing priority name parameter") + return inv.tags.stop(invTagsPriority, endTag, DRL_RET_INVALID_PARAM) + end -- if + + if (inv.priority.table[priorityName] == nil) then + operation = "Created" + else + operation = "Updated" + end -- if + + local priorityString = GetClipboard() + if (priorityString == nil) or (priorityString == "") then + dbot.warn("inv.priority.paste: Failed to get priority from clipboard") + return inv.tags.stop(invTagsPriority, endTag, DRL_RET_MISSING_ENTRY) + end -- if + + retval = inv.priority.update(priorityName, priorityString, true) + if (retval ~= DRL_RET_SUCCESS) then + dbot.warn("inv.priority.paste: Failed to update priority from clipboard data: " .. + dbot.retval.getString(retval)) + else + dbot.info(operation .. " priority \"@C" .. priorityName .. "@W\" from clipboard data") + end -- if return inv.tags.stop(invTagsPriority, endTag, retval) -end -- inv.priority.join +end -- inv.priority.paste function inv.priority.compare(priorityName1, priorityName2, endTag)