Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function consolidate(goal_items)
- org_message('Consolidating!')
- local current_items = Items.new()
- local dump_bags = get_dump_bags()
- local inventory_max = windower.ffxi.get_bag_info(0).max
- if current_items[0].n == inventory_max then
- tidy(goal_items,current_items,dump_bags)
- end
- if current_items[0].n == inventory_max then
- org_error('Unable to make space, aborting!')
- return
- end
- --now we have a list of items to not move, and are able to search over all inventory
- --iterate over every bag for things not in goal items and not in ignore
- countmoves=0
- for index,item in pairs(current_items[0]) do
- if item.id and res.items[item.id] and res.items[item.id].stack > 1 then
- local parent_bag_id = item._parent._info.bag_id
- local parent_bag_name = res.bags[parent_bag_id].en:lower()
- --org_debug('command','printing bag '..parent_bag_id)
- --org_debug('command',tostring(print_r(res.bags)))
- --print (res.items[item.id].english .. ' has stack '..res.items[item.id].stack )
- if (_ignore_list[parent_bag_name] and _ignore_list[parent_bag_name][res.items[item.id].english]) then
- org_verbose("Skipping "..res.items[item.id].english.." because it is on the ignore list!")
- else
- --local bag = current_items[parent_bag_id]
- --org_debug('command','bag is '..print_r(current_items))
- for bag_name,bag_id in pairs(settings.bag_priority) do
- if bag_id and bag_id ~=0 and current_items[bag_id] then
- local bag_max = windower.ffxi.get_bag_info(bag_id).max
- bag_count=0
- for _ in pairs(current_items[bag_id]) do bag_count = bag_count + 1 end
- --org_debug('command','max: '..bag_max..' count: '..tostring(bag_count))
- if bag_count ~= bag_max then
- local instances = current_items[bag_id]:find_all_instances(item)
- if instances then
- org_verbose("Moving stackable item "..res.items[item.id].english.." to "..res.bags[bag_id].en:lower())
- local dest_bag=bag_id
- --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
- _valid_dump[s_to_bag(bag_name)] = 1
- item:move(dest_bag)
- countmoves=countmoves+1
- end
- elseif bag_count == bag_max then
- org_warning(' Skipping '..bag_name..' because it is full!')
- end
- end
- end
- end
- end
- end
- --Clean up to play nice with other existing functions
- -- Re-Build a hard-wired dump list
- _valid_dump = {}
- for bag_name,_ in pairs(settings.dump_bags) do
- --org_verbose("Adding "..bag_name.." to the push list")
- _valid_dump[s_to_bag(bag_name)] = 1
- end
- -- Clean this
- current_items = nil
- dump_bags = nil
- -- Always allow inventory and wardrobe, obviously
- _valid_dump[0] = 1
- _valid_pull[0] = 1
- _valid_dump[8] = 1
- _valid_pull[8] = 1
- if countmoves > 0 then
- org_message('Consolidate Finished and saved you moving '..countmoves..' items >>> Have a nice day! ')
- else
- org_message('Consolidate Finished and found nothing worth moving based on what is in your bags!')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement