Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Include safe-list by ID in CS foreach Iteration?

Featured Replies

So from a great plugin called Butler Im trying to add a bit more functionality to what is trashes. Id like to include a safelist by item ID. The below code is what I have so far.

 

Obviously  

item.GetItemInfo.ItemID==12345 

isnt valid, but I think its clear what Im trying to do. If itemID of 12345 is found on the safelist, then do not continue onto destruction. Even if I can get a clue as to how to fill in a single item here, I can create an array later to fill in other IDs. 

 

	private void PulseDestroy() {
		if (ButlerSettings.CurrentSetting.DestroyGray) {
			foreach (WoWItem item in bagItems) {
				if (item.GetItemInfo.ItemRarity==0 || item.GetItemInfo.ItemRarity==1 && !item.GetItemInfo.ItemID==12345) {
					while (ObjectManager.Me.InCombat || ObjectManager.Me.IsDead) {Thread.Sleep(shortDelay);}
					List<int> BagAndSlot=Bag.GetItemContainerBagIdAndSlot(item.Entry);
					Logging.Write(ButlerPrefix+"destroying \""+item.GetItemInfo.ItemName+"\"");
					Lua.LuaDoString(string.Format("PickupContainerItem({0}, {1}); DeleteCursorItem()",(object) BagAndSlot[0],(object) BagAndSlot[1]),false);
					Thread.Sleep(shortDelay);
				}
			}
		}
	}

 

Hello you can use a hashset for this purpose like this:

private HashSet<int> safeList = new HashSet<int>
{
    12345,
    12346,
}

private void ProtectItem(WoWItem item)
{
    safeList.Add(item.GetItemInfo.ItemId);
}

private void ProtectItem(int itemId)
{
    safeList.Add(itemId);
}

private void PulseDestroy() 
{
    if (ButlerSettings.CurrentSetting.DestroyGray) 
    {
        foreach (WoWItem item in bagItems) 
        {
            if ((item.GetItemInfo.ItemRarity==0 
                || item.GetItemInfo.ItemRarity==1)
                && !safeList.Contains(item.GetItemInfo.ItemId)) 
            {
                while (ObjectManager.Me.InCombat || ObjectManager.Me.IsDead) 
                {
                    Thread.Sleep(shortDelay);
                }
                List<int> BagAndSlot=Bag.GetItemContainerBagIdAndSlot(item.Entry);
                Logging.Write(ButlerPrefix+"destroying \""+item.GetItemInfo.ItemName+"\"");
                Lua.LuaDoString(string.Format("PickupContainerItem({0}, {1}); DeleteCursorItem()",
                                (object) BagAndSlot[0],(object) BagAndSlot[1]),false);
                Thread.Sleep(shortDelay);
            }
        }
    }
}

 

Edited by reapler

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.