Zeroun_Scripts

OTCv8 Reward Chest

Dec 28th, 2020 (edited)
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.59 KB | None | 0 0
  1. macro(300, "Reward chest", function()
  2.     local rewardChest = 19250
  3.     local rewardBag = 19202
  4.     local rewardBagTotal = 0
  5.     local rewardBagCount = 1
  6.     local itemsToKeep = {}
  7.     local itemsToDrop = {}
  8.     local lootBp = 2869 --change this to the backpack you want items to move too
  9.        
  10.         --For every container open, get information on open containers
  11.         for i, container in pairs(getContainers()) do
  12.             --Get the IDs of every open container
  13.             containerId = container:getContainerItem():getId()
  14.             --If the containerId is equal to reward chest id then
  15.             if containerId == rewardChest then
  16.                 --Set rewardBagCount = items in rewardChest
  17.                 rewardBagTotal = container:getItemsCount()
  18.                 repeat    
  19.                     --For each rewardBag in rewardChest
  20.                     for j, item in ipairs(container:getItems()) do
  21.                         --Open the first bag and increase count by 1 until all bags equal rewardBagTotal
  22.                         g_game.open(item, container:getSlotPosition(rewardBagCount))
  23.                         rewardBagCount = rewardBagCount + 1
  24.                         --For every open container do
  25.                         for i, container in pairs(getContainers()) do
  26.                             containerBagId = container:getContainerItem():getId()
  27.                             --If reward bag is open then
  28.                             if containerBagId == rewardBag then
  29.                                 --For each item in reward bag
  30.                                 for l, item in ipairs(container:getItems()) do
  31.                                     --If the reward bag has items in it then
  32.                                     if container:getItemsCount() > 0 then
  33.                                         ----If the item id is found in itemsToKeep then
  34.                                         --if table.find(itemsToKeep, item:getId()) then
  35.                                             --For every container open
  36.                                             for k, container in pairs(getContainers()) do
  37.                                                 --Store container ids in this variable
  38.                                                 containerLootBp = container:getContainerItem():getId()
  39.                                                 --If containerLootBp ever matches lootBp
  40.                                                 if containerLootBp == lootBp then
  41.                                                     --Move the item from rewardbag to loot bag
  42.                                                     g_game.move(item, container:getSlotPostion(19))
  43.                                                 end
  44.                                             end
  45.                                         --end
  46.                                        
  47.                                         --If the item id is found in itemsToKeep then
  48.                                         --if table.find(itemsToDrop, item:getId()) then
  49.                                             --g_game.move(to floor)
  50.                                             --g_game.move(item, player:getPosition())
  51.                                         --end
  52.                                     end
  53.                                    
  54.                                     --if rewardbag has no items in it then
  55.                                     if container:getItemsCount() < 1 then
  56.                                         --for every container id open do
  57.                                         for containerId, container in pairs(g_game.getContainers()) do
  58.                                             --close each container found
  59.                                             g_game.close(container)
  60.                                         end
  61.                                         --reopen reward chest and restart the loop
  62.                                         for i, tile in ipairs(g_map.getTiles(posz())) do
  63.                                             for u,item in ipairs(tile:getItems()) do
  64.                                                 if (item and item:getId() == rewardChest) then
  65.                                                     g_game.use(item)
  66.                                                 end
  67.                                             end  
  68.                                         end
  69.                                     end
  70.                                 end
  71.                             end
  72.                         end
  73.                     end                        
  74.                 until(rewardBagCount > rewardBagTotal)
  75.             end
  76.         end
  77.     end)
Advertisement
Add Comment
Please, Sign In to add comment