zhxwbr8 1 Posted July 12, 2020 Share Posted July 12, 2020 Hello there~ For example: my backpack has ten items ID: 95302. I want to delete nine of them and keep only one in my backpack. How do I write commands? Link to comment https://wrobot.eu/forums/topic/12350-how-to-delete-redundant-items/ Share on other sites More sharing options...
scsfl 2 Posted July 13, 2020 Share Posted July 13, 2020 @Matenia has shared an example containing method you're looking for. zhxwbr8 1 Link to comment https://wrobot.eu/forums/topic/12350-how-to-delete-redundant-items/#findComment-59194 Share on other sites More sharing options...
Talamin 138 Posted July 13, 2020 Share Posted July 13, 2020 public static void DeleteItems(string itemName, int leaveAmount = 0) { var itemQuantity = ItemsManager.GetItemCountByNameLUA(itemName) - leaveAmount; if (string.IsNullOrWhiteSpace(itemName) || itemQuantity <= 0) { return; } string luaToDelete = $@" local itemCount = {itemQuantity}; local deleted = 0; for b=0,4 do if GetBagName(b) then for s=1, GetContainerNumSlots(b) do local itemLink = GetContainerItemLink(b, s) if itemLink then local itemString = string.match(itemLink, ""item[%-?%d:]+""); local _, stackCount = GetContainerItemInfo(b, s); local leftItems = itemCount - deleted; if ((GetItemInfo(itemString) == ""{itemName}"") and leftItems > 0) then if stackCount <= 1 then PickupContainerItem(b, s); DeleteCursorItem(); deleted = deleted + 1; else if (leftItems > stackCount) then SplitContainerItem(b, s, stackCount); DeleteCursorItem(); deleted = deleted + stackCount; else SplitContainerItem(b, s, leftItems); DeleteCursorItem(); deleted = deleted + leftItems; end end end end end end end "; Lua.LuaDoString(luaToDelete); } Directly out of Matenias Framework, and with DeleteItems("Soulshard", 5) usable. zhxwbr8 1 Link to comment https://wrobot.eu/forums/topic/12350-how-to-delete-redundant-items/#findComment-59196 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now