Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.87 KB | None | 0 0
  1. local status = 2
  2. local wait_time = 0
  3.  
  4. local get_available_item = function()
  5.     local list = {}
  6.     local backend_items = Managers.backend:get_interface("items")
  7.     local all_items = backend_items:get_all_backend_items()
  8.    
  9.     for backend_id, item in pairs(all_items) do
  10.         local power_level = item.power_level or 0
  11.         local rarity = item.rarity or ""
  12.         local career_equipped = backend_items:equipped_by(backend_id)
  13.        
  14.         if career_equipped and #career_equipped < 1 then
  15.             if power_level > 5 then
  16.                 if rarity == "plentiful" or rarity == "common" or rarity == "rare" or rarity == "exotic" then
  17.                     list[#list + 1] = backend_id
  18.                 end
  19.             end
  20.         end
  21.        
  22.         if #list == 9 then
  23.             return list
  24.         end
  25.     end
  26.    
  27.     return list
  28. end
  29.  
  30. local salvage_next_item = function()
  31.     local list = get_available_item()
  32.    
  33.     if #list > 0 then
  34.         -- Salvage item
  35.         Managers.state.crafting:craft(list)
  36.        
  37.         -- Debug
  38.         EchoConsole("Salvage " .. tostring(#list) .. " items")
  39.        
  40.         return true
  41.     else
  42.         Mods.exec("loadfile", "chest_gen")
  43.     end
  44.    
  45.     return false
  46. end
  47.  
  48. Mods.hook.set("", "BackendInterfaceCraftingPlayfab.craft_request_cb", function(func, self, id, result)
  49.     func(self, id, result)
  50.    
  51.     status = 2
  52. end)
  53.  
  54. Mods.hook.set("", "MatchmakingManager.update", function(func, self, dt, t)
  55.     safe_pcall(function()
  56.         if status == 0 then
  57.             if salvage_next_item() then
  58.                 status = 1
  59.             end
  60.         elseif status == 2 then
  61.             wait_time = t
  62.             status = 3
  63.         elseif status == 3 then
  64.             if wait_time + 1 < t then
  65.                 status = 0
  66.             end
  67.         end
  68.     end)
  69.    
  70.     return func(self, dt, t)
  71. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement