CarlZalph Posted November 18, 2017 Share Posted November 18, 2017 Since the UI doesn't have it as a feature and to unravel the dupes takes a lot of time if you have many and in all sorts of categories, I decided to make a script to do it automated. Do note that I have each item on a 3 second cooldown so you don't hammer Klei's servers. They have records of every item transaction with timestamps, so please don't make it go faster as you may have actions taken against your account for DDoSing their API server. The command itself has two modes of operation. cz_unravel_all_event_duplicates() Results in the script printing out your duplicates that it would have unraveled and how much currency you would get at the end of it. cz_unravel_all_event_duplicates("yes") Results in the script unraveling each duplicate item over time and you can see its progress in your console log. The "yes" parameter is a string type and must exist as a passed parameter to stop you from accidentally unraveling your duplicate forge-event items. Place this in the beginning of your customcommands.lua file to kill Strict: local OldStrict = getmetatable(_G) local NoStrict = {} setmetatable(_G, NoStrict) This can be placed inside your Klei/DoNotStarveTogether/customcommands.lua file. Spoiler function cz_unravel_all_event_duplicates(confirmation) if not ( scheduler and scheduler.ExecutePeriodic and TheInventory and TheInventory.GetFullInventory and TheInventory.GetCurrencyAmount and TheItems and TheItems.GetBarterBuyPrice and TheItems.GetBarterSellPrice and TheItems.BarterLoseItem ) then print("ERR: One of the core functions doesn't exist, and this script needs to be updated!") return end local all_items = TheInventory:GetFullInventory() local dupe_checker = {} local dupes = {} local dupes_size = 0 for _,item_data in pairs(all_items) do local item_type = string.lower(item_data.item_type) if TheItems:GetBarterBuyPrice(item_type) ~= 0 then local price_sell = TheItems:GetBarterSellPrice(item_type) if price_sell ~= 0 then if dupe_checker[item_type] == nil then dupe_checker[item_type] = true else local item_id = item_data.item_id table.insert( dupes, { item_type = item_type, price_sell = price_sell, item_id = item_id, } ) dupes_size = dupes_size + 1 end end end end if dupes_size > 0 then if confirmation == "yes" then if cz_unravel_timer ~= nil then cz_unravel_timer:Cancel() cz_unravel_timer = nil end cz_unravel_timer = scheduler:ExecutePeriodic( 3.0, function() local dupe = table.remove(dupes) local item_type = dupe.item_type local price_sell = dupe.price_sell local item_id = dupe.item_id print("Selling:", item_type, price_sell, item_id) TheItems:BarterLoseItem( item_id, price_sell, function(success, status) if success then print("Item", item_type, item_id, "successfully sold for", price_sell, " :: ", status) else print("Item", item_type, item_id, "FAILED to sell for", price_sell, "because of:", status) end end ) if #dupes == 0 then cz_unravel_timer:Cancel() cz_unravel_timer = nil print("All duplicates finished trying to unravel.") end end ) else print("This is a listing of all of your duplicate items.") local spools = 0 for i,v in ipairs(dupes) do local price_sell = v.price_sell print(i, v.item_type, price_sell) spools = spools + price_sell end print("You would gain:", spools) print("Which would put you at:", spools + TheInventory:GetCurrencyAmount()) end else print("You have no duplicate items to unravel.") end end If there are any crashes resulting from you switching menus, entering servers, or what have you then I put the blame solely on you. Let the script finish before doing anything else, lest you explode something. Edit: And here's one for chests. It has one mode of operation as leaving unopened chests isn't potentially harmful as far as I'm aware of. cz_open_all_chests() Results in the script opening each chest over time and you can see its progress in your console log. Spoiler function cz_open_all_chests() if not ( scheduler and scheduler.ExecutePeriodic and TheInventory and TheInventory.GetFullInventory and TheItems and TheItems.OpenBox and GetTypeForItem ) then print("ERR: One of the core functions doesn't exist, and this script needs to be updated!") return end local all_items = TheInventory:GetFullInventory() local chests = {} local chests_size = 0 for _,item_data in pairs(all_items) do local item_type = string.lower(item_data.item_type) if GetTypeForItem(item_type) == "mysterybox" then table.insert( chests, { item_type = item_type, item_id = item_data.item_id, } ) chests_size = chests_size + 1 end end if chests_size > 0 then if cz_chestopener_timer ~= nil then cz_chestopener_timer:Cancel() cz_chestopener_timer = nil end cz_chestopener_timer = scheduler:ExecutePeriodic( 3.0, function() local chest = table.remove(chests) local item_type = chest.item_type local item_id = chest.item_id print("Opening:", item_type, item_id) TheItems:OpenBox( item_id, function(success, items_gained) if success and #items_gained ~= 0 then print("Chest", item_type, item_id, "successfully opened, and you obtained:") for i,v in ipairs(items_gained) do print(i, v) end else print("Chest", item_type, item_id, "FAILED to open for unknown reasons.") end end ) if #chests == 0 then cz_chestopener_timer:Cancel() cz_chestopener_timer = nil print("All chests finished trying to open.") end end ) else print("You have no chests to open.") end end Link to comment Share on other sites More sharing options...
CarlZalph Posted November 22, 2017 Author Share Posted November 22, 2017 Fixed an issue for the chests script stopping at the first chest always, if you're using it. if #chest == 0 -> if #chests == 0 Link to comment Share on other sites More sharing options...
obzerverlk Posted December 3, 2017 Share Posted December 3, 2017 when i use cz_unravel_all_forge_duplicates("yes"), it showed [string "function cz_unravel_all_forge_duplicates(co..."]:45: variable 'cz_unravel_timer' is not declared and i add the "local cz_unravel_timer = nil" try to fix it ..it's working now. but i think each item should be at least 5 second cooldown...or you'll find that items cann't be selling success by one time. Link to comment Share on other sites More sharing options...
CarlZalph Posted December 3, 2017 Author Share Posted December 3, 2017 5 hours ago, obzerverlk said: when i use cz_unravel_all_forge_duplicates("yes"), it showed [string "function cz_unravel_all_forge_duplicates(co..."]:45: variable 'cz_unravel_timer' is not declared and i add the "local cz_unravel_timer = nil" try to fix it ..it's working now. but i think each item should be at least 5 second cooldown...or you'll find that items cann't be selling success by one time. It's probably strict messing with it. I have strict disabled as it stops variables from entering _G without first declaring them using its own function, which I find to be a pain when writing scripts. To disable Strict: local OldStrict = getmetatable(_G) local NoStrict = {} setmetatable(_G, NoStrict) Link to comment Share on other sites More sharing options...
HBConstantine Posted January 1, 2018 Share Posted January 1, 2018 Is this still working? Link to comment Share on other sites More sharing options...
CarlZalph Posted January 15, 2018 Author Share Posted January 15, 2018 On 1/1/2018 at 6:26 AM, HBConstantine said: Is this still working? Yeah, and it also works for the winter's veil event and will work for any future event that has items both weavable and unravelable. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.