Cool VL Viewer forum
http://sldev.free.fr/forum/

Count of worn attachments in inventory floaters Worn tab?
http://sldev.free.fr/forum/viewtopic.php?f=9&t=2089
Page 1 of 1

Author:  kathrine [ 2020-11-16 22:02:18 ]
Post subject:  Count of worn attachments in inventory floaters Worn tab?

Hi,

for various reasons i tend to hit the max attachment limits quite frequently.
It would be nice if the worn tab in the inventory panel could show the number of worn attachments counting against the limit, to see how many are left.
Can obviously done by manual counting too, but well, being lazy...

If you could give me a hint where to look in the code i could probably come up with a patch myself.

Thx,
Kathrine

Author:  Henri Beauchamp [ 2020-11-17 16:07:57 ]
Post subject:  Re: Count of worn attachments in inventory floaters Worn tab

For all such specific purposes, I implemented Lua scripting... :P

Code:
function GetOutfitStats()
   local k, v

   -- Count the number of attachments currently worn
   local attach_count = 0
   local attached = GetAgentAttachments()
   for k, v in pairs(attached) do
      attach_count = attach_count + 1
   end

   -- Count the number of wearable items, detailing the number of layers for each item type
   local wearable_count = 0
   local wearables = {}
   local worn = GetAgentWearables()
   for k, v in pairs(worn) do
      wearable_count = wearable_count + 1
      local i = string.find(v, "|")
      local w = string.sub(v, i + 1)
      if wearables[w] then
         wearables[w] = wearables[w] + 1
      else
         wearables[w] = 1
      end
   end
   local report = "Wearing " .. attach_count .. " attachments ("
   report = report .. GetAgentInfo()["attachment_limit"] - attach_count .. " slot(s) left) and "
   report = report .. wearable_count .. " wearable items"
   for k, v in pairs(wearables) do
      report = report .. " - " .. v .. " x " .. k
   end
   return report
end

print(GetOutfitStats())


You may simply add the GetOutfitStats() function to your automation.lua script and bind it to either a Lua pie menu slice, a Lua side-bar button, or use it in an OnSendChat() callback, associating it for example to an "/os" (for outfit stats) pseudo-gesture. And of course, instead of printing the report in the chat console, you may use a Lua notification... Example:
Code:
function OnSendChat(text)
   if text == "/os" then
      OpenNotification(1, GetOutfitStats())
      return ""
   end
   return text
end


EDIT (2020-11-21): added today's viewer release attachments limit support (via GetAgentInfo()) in GetOutfitStats().

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/