Jump to content

Convenient Bags (1.8.2)


RoboMat

Recommended Posts

  • 1 year later...

Edit: The unpack magic is elsewhere.... 

 

There's a chunk of code that eats a random item every time you unpack.

		elseif type(itemTable[i1]) == "table" then			-- We start to iterate at the second index to jump over the dummy			-- item that is contained in the item-table.			for i2 = 2, #itemTable[i1].items do				local item = itemTable[i1].items[i2];				if instanceof(item, "InventoryItem") and instanceof(item, "InventoryContainer") then					local bag = item;					local itemsInContainer = table.convertArrayList(bag:getInventory():getItems());					if #itemsInContainer > 0 then						context:addOption("Unpack (" .. #itemsInContainer .. " Items)", itemTable, onUnpackBag, player, itemsInContainer, bag);					end				end			end		end

Changing i2 = 1 only adds an extra unpack option... the unpack magic is elsewhere....

Link to comment
Share on other sites

The actual unpacking happens in the TimedAction:

function TAUnpackBag:perform()	local player = self.character;	local bag = self.bag;	local inventory = bag:getInventory(); -- Get the bag's inventory.	local container = bag:getContainer(); -- Get the container in which the bag itself is contained.	-- Remove all items from the baggage container.	inventory:removeAllItems();	-- Now we move all the items from the bag to the container.	container:setDrawDirty(true);	for _, item in ipairs(self.itemsInBag) do		if item then			-- If the floor is selected add the items to the ground.			if container:getType() == "floor" then				player:getCurrentSquare():AddWorldInventoryItem(item, 0.0, 0.0, 0.0);			else				container:AddItem(item);			end		end	end	-- Make sure we refresh the inventory so the items show up.	local pdata = getPlayerData(player:getPlayerNum());	if pdata then		pdata.playerInventory:refreshBackpacks();		pdata.lootInventory:refreshBackpacks();	end	-- Remove Timed Action from stack.	ISBaseTimedAction.perform(self);end
But I guess the problem might be caused by this (Line 64 in UIUnpackBagsMenu.lua):

local itemsInContainer = table.convertArrayList(bag:getInventory():getItems());
Might be worth writing a few tests to check if this returns all the items in the inventory.
Link to comment
Share on other sites

Updated to work with the latest version of PZ. Modding utilities are no longer needed.

 

### Version 1.1.0- Added special menu entries for one and multiple objects- Added possiblity for translations	- Added german translation	- Added finnish translation	- Added french translation- Fix #1: Items are no longer deleted- Updated folder structure to make the mod work with the latest version of PZ- Remove utility dependencies (no extra files are needed to run the mod)
Link to comment
Share on other sites

  • 2 weeks later...

I really wanted to say thank you so much for this mod. It's really going to help out and it's not a game breaking thing. If we can put things in a bag all at one time, logically we can unpack them too! Really, really neat idea that needed to be done. Again you have my utmost thanks from someone like me who can't even begin to understand how to code things and was wishing for something like this!

Link to comment
Share on other sites

I really wanted to say thank you so much for this mod. It's really going to help out and it's not a game breaking thing. If we can put things in a bag all at one time, logically we can unpack them too! Really, really neat idea that needed to be done. Again you have my utmost thanks from someone like me who can't even begin to understand how to code things and was wishing for something like this!

 

Thanks, glad you like it :)

Link to comment
Share on other sites

Any chance this could work with bags/containers on the ground? I'm using the Hydrocraft mod and have a dolly sitting on the ground that's too heavy to pick up and unpack. =(

It should. When the bag is on the floor it comes up in the world inventory window and you should be getting the "Unpack xy items" option when you right click on it.

Link to comment
Share on other sites

Tried it on that dolly, it won't unpack if the total items' weight is higher than the space's capacity.

 

Yes that's by design. If I'd allow people to unpack items into containers with insufficient capacity it would be an exploit, since you could fill a bag way over its originally intended maximum.

 

A possible "fix" would be to only allow parts of the bag until the container is full. This way you could empty a huge bag over multiple containers.

Link to comment
Share on other sites

Pushed Version 1.3.0

### Version 1.3.0- Duration of the TimeAction is now dependent on the amount of items in the bag- Bags can now be partially emptied if the target container is too small to hold all the items (Closes #4)- Fixed #2: Items are now placed on the bag's IsoSquare
Link to comment
Share on other sites

How about the inverse? Clicking on a bag in a container allows you to put the rest of the container in that bag?

 

I've recently been packing for a move from the northwest warehouse to the sunstar hotel. It was a lot of juggling items. Being able to put items into containers and then quickly wrap them into bags would have saved me quite some effort. 

 

I might be doing it again soon. Cuz.. You know I accidentally all the house alarms in the area. And now everyone is checking in.. There apears to be a skin cream convention in the area. (And between us, most of the guests need it...)

 

Though the goth girl in room 2 is kinda hot...

 

Anyway it's only some interface magic, nothing OP game wise...

Link to comment
Share on other sites

How about the inverse? Clicking on a bag in a container allows you to put the rest of the container in that bag?

 

This would require an InventoryContextMenu option. The mod should then iterate over all items in the same container as the bag, ignoring the bag itself and any items that are equipped on the player.

It should then transfer each item into the bag until the bag is full.

There shouldn't be any time bonus for using this method, so the default TimedAction can be used for the transfer.

 

Will see if I can get this done today.

Link to comment
Share on other sites

Released Version 1.6.0:

### Version 1.6.0- Added support for quickly packing a bag	- Can be selected in the inventory screen and will grab all items in the same container as the bag	- Ignores bags and equipped items- Changed folder structure and added a mod id
05ab1ca4-2825-11e5-8d95-9d1568705c04.png

 

Hi Robomat, thanks a lot for this great mod, it's really good and useful.

You are very good!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...