Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. function consolidate(goal_items)
  2. org_message('Consolidating!')
  3. local current_items = Items.new()
  4. local dump_bags = get_dump_bags()
  5.  
  6. local inventory_max = windower.ffxi.get_bag_info(0).max
  7. if current_items[0].n == inventory_max then
  8. tidy(goal_items,current_items,dump_bags)
  9. end
  10. if current_items[0].n == inventory_max then
  11. org_error('Unable to make space, aborting!')
  12. return
  13. end
  14. --now we have a list of items to not move, and are able to search over all inventory
  15. --iterate over every bag for things not in goal items and not in ignore
  16. countmoves=0
  17. for index,item in pairs(current_items[0]) do
  18. if item.id and res.items[item.id] and res.items[item.id].stack > 1 then
  19. local parent_bag_id = item._parent._info.bag_id
  20. local parent_bag_name = res.bags[parent_bag_id].en:lower()
  21.  
  22. --org_debug('command','printing bag '..parent_bag_id)
  23. --org_debug('command',tostring(print_r(res.bags)))
  24. --print (res.items[item.id].english .. ' has stack '..res.items[item.id].stack )
  25. if (_ignore_list[parent_bag_name] and _ignore_list[parent_bag_name][res.items[item.id].english]) then
  26. org_verbose("Skipping "..res.items[item.id].english.." because it is on the ignore list!")
  27. else
  28. --local bag = current_items[parent_bag_id]
  29. --org_debug('command','bag is '..print_r(current_items))
  30. for bag_name,bag_id in pairs(settings.bag_priority) do
  31. if bag_id and bag_id ~=0 and current_items[bag_id] then
  32. local bag_max = windower.ffxi.get_bag_info(bag_id).max
  33. bag_count=0
  34. for _ in pairs(current_items[bag_id]) do bag_count = bag_count + 1 end
  35. --org_debug('command','max: '..bag_max..' count: '..tostring(bag_count))
  36. if bag_count ~= bag_max then
  37. local instances = current_items[bag_id]:find_all_instances(item)
  38. if instances then
  39. org_verbose("Moving stackable item "..res.items[item.id].english.." to "..res.bags[bag_id].en:lower())
  40. local dest_bag=bag_id
  41.  
  42. --Consolidate has to ignore valid dump bags if it's going to do its job, rebuild at function end the valid dumps for other modes
  43. _valid_dump[s_to_bag(bag_name)] = 1
  44. item:move(dest_bag)
  45. countmoves=countmoves+1
  46. end
  47. elseif bag_count == bag_max then
  48. org_warning(' Skipping '..bag_name..' because it is full!')
  49. end
  50. end
  51. end
  52. end
  53. end
  54. end
  55. --Clean up to play nice with other existing functions
  56. -- Re-Build a hard-wired dump list
  57. _valid_dump = {}
  58. for bag_name,_ in pairs(settings.dump_bags) do
  59. --org_verbose("Adding "..bag_name.." to the push list")
  60. _valid_dump[s_to_bag(bag_name)] = 1
  61. end
  62. -- Clean this
  63. current_items = nil
  64. dump_bags = nil
  65. -- Always allow inventory and wardrobe, obviously
  66. _valid_dump[0] = 1
  67. _valid_pull[0] = 1
  68. _valid_dump[8] = 1
  69. _valid_pull[8] = 1
  70.  
  71. if countmoves > 0 then
  72. org_message('Consolidate Finished and saved you moving '..countmoves..' items >>> Have a nice day! ')
  73. else
  74. org_message('Consolidate Finished and found nothing worth moving based on what is in your bags!')
  75. end
  76.  
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement