Added as-on and as-off commands to disable/reenable autosell

willneedit [11-18-18 - 10:10]
Added as-on and as-off commands to disable/reenable autosell
Filename
InventoryManager.lua
Modules/Seller.lua
lang/de.lua
lang/en.lua
diff --git a/InventoryManager.lua b/InventoryManager.lua
index e1fc3c0..e6e2cef 100644
--- a/InventoryManager.lua
+++ b/InventoryManager.lua
@@ -156,6 +156,8 @@ function IM:help()
 	CHAT_SYSTEM:AddMessage("/im listrules - list the rules currently defined")
 	CHAT_SYSTEM:AddMessage("/im dryrun    - show what the currently defined rules would do to your inventory")
 	CHAT_SYSTEM:AddMessage("/im run       - make a pass of the filters over your inventory")
+	CHAT_SYSTEM:AddMessage("/im as-off    - Quickly disable autosell")
+	CHAT_SYSTEM:AddMessage("/im as-on     - Quickly enable autosell")
 	CHAT_SYSTEM:AddMessage("/im settings  - Open up the settings menu")
 end

@@ -168,7 +170,9 @@ function IM:SlashCommand(argv)
         end
     end

-	if #options == 0 or options[1] == "help" then
+	if #options == 0 then
+		self:OpenSettings()
+	elseif options[1] == "help" then
 		self:help()
 	elseif options[1] == "listrules" then
 		self:listrules()
@@ -178,6 +182,12 @@ function IM:SlashCommand(argv)
 		self:run()
 	elseif options[1] == "settings" then
 		self:OpenSettings()
+	elseif options[1] == "as-off" then
+		IM.settings.autosell = false
+		self:ReportASState(false)
+	elseif options[1] == "as-on" then
+		IM.settings.autosell = true
+		self:ReportASState(false)
 	else
 		CHAT_SYSTEM:AddMessage("Unknown parameter '" .. argv .. "'")
 	end
@@ -199,7 +209,7 @@ function IM:InitializeUI()
 		name = "InventoryManager",
 		author = "iwontsay & iFedix",
 		version = ADDON_VERSION,
-		slashCommand = "/im",
+		-- slashCommand = "/im", -- Nope. This would completely remove the commandline parsing we need.
 		registerForRefresh = true,	--boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown)
 		registerForDefaults = true,
 		website = ADDON_WEBSITE,
@@ -324,9 +334,10 @@ function IM:Init()
 	self:Update()
 	self:InitializeUI()

+	self:ReportASState(true)
+
 	CHAT_SYSTEM:AddMessage(self.name .. " Addon Loaded.")
-	CHAT_SYSTEM:AddMessage("Use /im help for an overview")
-
+	CHAT_SYSTEM:AddMessage("Use /im help for an overview")
 end

 function IM:Save()
diff --git a/Modules/Seller.lua b/Modules/Seller.lua
index 2d6eeea..ecb7ccf 100644
--- a/Modules/Seller.lua
+++ b/Modules/Seller.lua
@@ -37,6 +37,18 @@ local function filter_for_launder(data)
 	return true
 end

+function IM:ReportASState(currently)
+	local currentlystr
+	if(currently) then
+		currentlystr = GetString(IM_LOG_ASSTATE_CURRENTLY)
+	end
+	if(IM.settings.autosell) then
+		CHAT_SYSTEM:AddMessage(zo_strformat(GetString(IM_LOG_ASSTATE_ON), currentlystr))
+	else
+		CHAT_SYSTEM:AddMessage(zo_strformat(GetString(IM_LOG_ASSTATE_OFF), currentlystr))
+	end
+end
+
 function IM:SellItems(stolen)
 	local list = { }
 	local end_fn = function(abort, eventCode, itemName, itemQuantity, money)
diff --git a/lang/de.lua b/lang/de.lua
index 80c0de6..6ef58c0 100644
--- a/lang/de.lua
+++ b/lang/de.lua
@@ -236,7 +236,11 @@ local lang = {
 	IM_R2_FORMAT0     			= "Kein <<1>><<z:2>><<z:3>> <<4>>",         -- Rule V2 text, negative
 	IM_R2_FORMAT1     			= "Jeder <<1>><<z:2>><<z:3>> <<4>>",        -- Rule V2 text, positive
   IM_R2_FORMAT2           = "Nichts von der Liste '<<z:1>>' <<2>>",   -- Rule V2 text, cross reference, negative
-  IM_R2_FORMAT3           = "Alles von der Liste '<<z:1>>' <<2>>"     -- Rule V2 text, cross reference, positive
+  IM_R2_FORMAT3           = "Alles von der Liste '<<z:1>>' <<2>>",    -- Rule V2 text, cross reference, positive
+
+  IM_LOG_ASSTATE_ON		  	= "Autosell ist <<1>>an.",
+  IM_LOG_ASSTATE_OFF	  	= "Autosell ist <<1>>AUS. Es kann mit /im as-on wieder eingeschaltet werden.",
+  IM_LOG_ASSTATE_CURRENTLY	= "zurzeit "

 }

diff --git a/lang/en.lua b/lang/en.lua
index 8d66cbd..50d9a60 100644
--- a/lang/en.lua
+++ b/lang/en.lua
@@ -236,8 +236,11 @@ local lang = {
 	IM_R2_FORMAT0     			= "No <<1>><<z:2>><<z:3>> <<4>>",               -- Rule V2 text, negative
 	IM_R2_FORMAT1     			= "Any <<1>><<z:2>><<z:3>> <<4>>",              -- Rule V2 text, positive
   IM_R2_FORMAT2           = "Nothing from the list '<<z:1>>' <<2>>",      -- Rule V2 text, cross reference, negative
-  IM_R2_FORMAT3           = "Everything from the list '<<z:1>>' <<2>>"   	-- Rule V2 text, cross reference, positive
+  IM_R2_FORMAT3           = "Everything from the list '<<z:1>>' <<2>>",   	-- Rule V2 text, cross reference, positive

+  IM_LOG_ASSTATE_ON		  	= "Autosell is <<1>>on.",
+  IM_LOG_ASSTATE_OFF	  	= "Autosell is <<1>>OFF. You can use /im as-on to switch it back on.",
+  IM_LOG_ASSTATE_CURRENTLY	= "currently "
 }

 for stringId, stringValue in pairs(lang) do