EC: Stop Loot All, Organizer, and Restock if overweight, too many items, or container is closed

In the EC the Loot All and Organizer will continue to run forever if the destination container is overweight or as too many item.  Loot All, Organizer, and Restock will continue to run forever if the source container is closed.  The following code will stop them from running forever.

To the file source\ContainerWindow.lua add the following functions
--start of added code
function ContainerWindow.StopLootAll()
local oldOrganizeParent = ContainerWindow.OrganizeParent
ContainerWindow.OrganizeParent = WindowGetId(WindowUtils.GetActiveDialog())

if(oldOrganizeParent ~= nil and oldOrganizeParent ~= ContainerWindow.OrganizeParent)then
ContainerWindow.LootAll[oldOrganizeParent] = nil
end

if(ContainerWindow.OrganizeParent ~= nil) then
ContainerWindow.LootAll[ContainerWindow.OrganizeParent] = nil
end
moveObjects = {} -- cleanup
end

function ContainerWindow.StopOrganizer()
Actions.MassOrganize = false -- abort organizer
ContainerWindow.Organize = false -- enable the button
moveObjects = {} -- cleanup
end

function ContainerWindow.StopRestock()
ContainerWindow.Restock = false -- enable the button
end
--end of added code

Add the following code to the bottom of the function ContainerWindow.UpdatePickupTimer in the file source\ContainerWindow.lua

--start of added code
local organizerParentOpen = false
--end of added code
for id, value in pairs(ContainerWindow.OpenContainers) do
if ContainerWindow.OpenContainers[id] ~= nil then
--start of added code
if(id == ContainerWindow.OrganizeParent) then
organizerParentOpen = true
end
--end of added code
local isDirty = ContainerWindow.OpenContainers[id].dirty
if(isDirty == 1 and ContainerWindow.OpenContainers[id].LastUpdate and ContainerWindow.OpenContainers[id].LastUpdate < ContainerWindow.DeltaRefresh)then
ContainerWindow.UpdateContents(id)
if (ContainerSearch.Container == id) then
ContainerSearch.UpdateList()
end
end
end
end

--start of added code
if(organizerParentOpen == false) then -- stop organizer, restock, loot all
ContainerWindow.StopOrganizer()
ContainerWindow.StopRestock()
ContainerWindow.StopLootAll()
end
--end of added code
end

Add the following code to the function TextParsing.SpecialTexts in the file source\TextParsing.lua
(Note: this code replaces the code added in the post: https://forum.uo.com/discussion/13267/ec-stop-loot-all-from-running-forever-if-the-loot-bag-can-not-hold-more-weight
function TextParsing.SpecialTexts()
local senderText = SystemData.Text
local find = wstring.find

--start of added code
if ( senderText ~= nil) then
local tooMuchWeight = GetStringFromTid(1080016) -- "That container cannot hold more weight."
local tooManyItems = GetStringFromTid(1080017) -- "That container cannot hold more items."
if( senderText == tooMuchWeight or senderText == tooManyItems) then
ContainerWindow.StopOrganizer()
ContainerWindow.StopLootAll()
return
end
end
--end of added code

Comments

  • @TimSt what would the command be to press the loot all on an open container, say a corpse?

    A Goblin, a Gargoyle, and a Drow walk into a bar . . .

    Never be afraid to challenge the status quo

  • MariahMariah Posts: 2,994Moderator
    Actually, I usually just press the button 'stop organiser' or 'stop looting' whichever is relevant. Often in a complete panic because I accidentally caught the 'loot all' icon and it's trying to empty one of my secures into my back pack :D. A running organiser can also make a bag appear empty when it's not.
  • Mariah said:
    Actually, I usually just press the button 'stop organiser' or 'stop looting' whichever is relevant. Often in a complete panic because I accidentally caught the 'loot all' icon and it's trying to empty one of my secures into my back pack :D. A running organiser can also make a bag appear empty when it's not.
    I stop it that way too, i'm looking for the command to start it within a macro. and on the "empty bag"
     you can just hit the "view" button (green cross) twice and it pops them into view again. and irealize the way to do it is probably within this list, but i am too illiterate with coding to see it lol

    A Goblin, a Gargoyle, and a Drow walk into a bar . . .

    Never be afraid to challenge the status quo

  • MariahMariah Posts: 2,994Moderator
    just stop the organiser :D
  • Arroth_ThaielArroth_Thaiel Posts: 1,030
    ...what would the command be to press the loot all on an open container, say a corpse?

    ... i'm looking for the command to start it within a macro. ...
    Actions> Other> Vacuum

    Vacuum pushes the LootAll button. 

    --
    You can write a LootAll script command, but it ends up being a multi-line script, if I remember correctly, as you have to also identify the corpse (container) you want to execute LootAll on. 

    It's easier to just use Vacuum.  
    -Arroth
  • TimStTimSt Posts: 1,801
    edited January 19
    The macro command for pressing the loot all button on the currently open and targeted container / corpse is:
    script ContainerWindow.LootAllBtn()



  • TimSt said:
    The macro command for pressing the loot all button on the currently open and targeted container / corpse is:
    script ContainerWindow.LootAllBtn()



    Thank you. Greatly appreciated.

    A Goblin, a Gargoyle, and a Drow walk into a bar . . .

    Never be afraid to challenge the status quo

  • ...what would the command be to press the loot all on an open container, say a corpse?

    ... i'm looking for the command to start it within a macro. ...
    Actions> Other> Vacuum

    Vacuum pushes the LootAll button. 

    --
    You can write a LootAll script command, but it ends up being a multi-line script, if I remember correctly, as you have to also identify the corpse (container) you want to execute LootAll on. 

    It's easier to just use Vacuum.  
    Thank you, that actually solved another item i was working on.
    A Goblin, a Gargoyle, and a Drow walk into a bar . . .

    Never be afraid to challenge the status quo

  • Arroth_ThaielArroth_Thaiel Posts: 1,030
    Hey Vic,

    My apologies, but Vacuum does not push LootAll. Vacuum pushes the organizer agent.

    I was using LootAll, but didn't like the way it worked, so I wrote a catch-all organizer called "Loot", which Vacuum is executing. In answering you I conflated LootAll and Loot.

    Anyway, good luck!

    -Arroth
  • Hey Vic,

    My apologies, but Vacuum does not push LootAll. Vacuum pushes the organizer agent.

    I was using LootAll, but didn't like the way it worked, so I wrote a catch-all organizer called "Loot", which Vacuum is executing. In answering you I conflated LootAll and Loot.

    Anyway, good luck!

    It worked out fine, you tie it to a specific Organizer, say one with only feathers. then make a macro to use a skinning knife on the corpse, then open the corpse and use vcuum to put only the feathers in your pouch. Thank you again, I never put two and two together on the vacuum thing. 
    A Goblin, a Gargoyle, and a Drow walk into a bar . . .

    Never be afraid to challenge the status quo

Sign In or Register to comment.