Jump to content

"Drop All" button into loot window


igormaozao

Recommended Posts

Hi,

 

I've been trying to create a mod by myself, but I didn't find a good documentation about it.

 

Anyway, I want to add a button in the inventory window to "Drop all" items from that container into the floor, it's kinda anoying when I need to empty a container to destroy it, so I was trying to find a easy way to drop all items from the current loot container into the floor.

 

Thanks

Link to comment
Share on other sites

Hey, do something like this:

 

local ISInventoryPagecreateChildren = ISInventoryPage.createChildren

function ISInventoryPage:createChildren()
    ISInventoryPagecreateChildren(self)
	local titleBarHeight = self:titleBarHeight();
	local textWidth = getTextManager():MeasureStringX(UIFont.Small, "your_text");
	local button = ISButton:new(0, 0, textWidth, titleBarHeight, "your_text", self, your_function);
	button:initialise();
	button.tooltip = "your_tooltip"
	button.borderColor.a = 0.0;
	button.backgroundColor.a = 0.0;
	button.backgroundColorMouseOver.a = 0.7;
	self:addChild(button);
	button:setVisible(true);
	-- I'd also expose button for other mods if planning to release public
	self.MY_MOD_BUTTON_NAME = button
end

 

or check out my mod's source here https://github.com/SharePickle/easy-drop-n-loot/blob/master/media/lua/client/KADropnLoot/KAInventoryPageButtons.lua

Link to comment
Share on other sites

11 hours ago, Ysa said:

 

Hey, thanks for the help, to be honest I found your source before and I was using it inspired in that piece of code, and I could add the button itself, but I couldn't make the real action to get the current "loot inventory" container and the "floor" container and add the action to move all items.

Link to comment
Share on other sites

Try 
 

local floorContainer = ISInventoryPage.GetFloorContainer(self.player)

 

I was looking through PZ's own lua, this file ISInventoryPage.lua is very helpful to understand what's what with containers in PZ.

You can find game sources here <path>\ProjectZomboid\media\lua

 

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...