Jump to content

Creating meta containers.


Dirmagnos

Recommended Posts

Ive been at it for like 3 days and i have kinda hit the wall, like Chinas Great Wall, im completely out of ideas.

I love the game, but in terms of sorting and organizing its a bust. Sure, its fairly easy when youre at your base surrounded by boxes/cupboards/crates/etc, but when out in the field its extremely basic. And juggling all those backpacks around is really really really annoying. Not to mention i really dislike to let go of my weapon with all those zeds wanting a hug.

Ok, enough of crying.

With realease of keyring(i play game on/off every now and then) i finally thought that i can get it, create containers/categories in player inventory without need to go thru 3-4-x bags to store items by categories.

So i made a few containers with own icons(like medical bag for meds, or toolbag for tools), they dont give any weight reduction bonus, weigh nothing, and have (more or less)unlimited capacity, so they still depend on players own carrying weight. But they were supposed to act similar to keyring, giving me a subcontainers without needing to equip them as long as i have them in my inventory(even tho i dont like to clitter inventory with additional items, i cant see an alternative).

And i completely failed there, they still need to be equipped, meaning whole thing was for nothing.

Ideally id like an option to simply add subcategories in inventory. In a similar way that equipping container(like backpack) adds containers inventory on the right side of the inventroy. Or at least containers that dont need to be equipped(or can be equipped in some non-invasive theorectical slot like keyring). Or point me to script that deals with keyring being usable container without needing to be equipped.

 

3aNYSxQ.jpg?1

 

Pls tell me it can be done. And how it can be done.

And i did try to search forum, but im coming up empty. Sorry for (maybe)stupid questions, but im at the end of my rope here and my gaming ocd demands actions.

Thx

Link to comment
Share on other sites

I just checked if I could do it and You can make a container "autoequip" and work just like the keyring. The answer you're looking for can be found in this file.

 

E:\Steam\steamapps\common\ProjectZomboid\media\lua\client\ISUI\ISInventoryPage.lua

 

The code you want to look at is this part.

            if item:getCategory() == "Container" and getSpecificPlayer(self.player):isEquipped(item) or item:getType() == "KeyRing" then                -- found a container, so create a button for it...                local containerButton = ISButton:new(self.width-32, ((c-1)*32)+15, 32, 32, "", self, ISInventoryPage.selectContainer, ISInventoryPage.onBackpackMouseDown, true);                containerButton:setImage(item:getTex());                containerButton:forceImageSize(30, 30)                containerButton.anchorBottom = false;                containerButton:setOnMouseOverFunction(ISInventoryPage.onMouseOverButton);                containerButton:setOnMouseOutFunction(ISInventoryPage.onMouseOutButton);                containerButton.anchorRight = true;                containerButton.anchorTop = false;                containerButton.anchorLeft = false;                containerButton:initialise();                containerButton.borderColor.a = 0.0;                containerButton.backgroundColor.a = 0.0;                containerButton.backgroundColorMouseOver = {r=0.3, g=0.3, b=0.3, a=1.0};                containerButton.inventory = item:getInventory();                containerButton.capacity = item:getEffectiveCapacity(playerObj);                containerButton.name = item:getName();                if self.inventoryPane.inventory == containerButton.inventory then                    containerButton.backgroundColor = {r=0.7, g=0.7, b=0.7, a=1.0};                    foundIndex = c;                    found = true;                end                self:addChild(containerButton);                self.backpacks[c] = containerButton;                c = c + 1;            end

If you wanted to, say, make First Aid Kit work like they keyring, being forever equipped without the need to actually equip it, you just make one simple modification to one line. Like below

if item:getCategory() == "Container" and getSpecificPlayer(self.player):isEquipped(item) or item:getType() == "KeyRing" or item:getType() == "FirstAidKit" then

It's probably possible to do it without modifying the game file or replacing it by means of a mod but I wouldn't know how to do it efficiently. I kind of suck with .lua coding.

Hope this helps you get started.

Also, thank you, now that I made that modification I'm much happier with carrying a First Aid Kit around. Thanks for giving the motivation to finally mod it :P

 

Note: item:getType() == "FirstAidKit"

"FirstAidKit" < This is the ItemID, it doesn't require a module or anything, you just put the same ItemID as in the script. Item type should be container, I just tested this by creating a random Pouch item for this purpose. Screen Below, all equip slots are taken, pouch works.

q85IV8z.png

Edit: I'm looking into making it not require editing or completely replacing the game file.

Link to comment
Share on other sites

Thx a ton, worked great.

But another stupid question.

Mod is supposed to spawn 6 different items, but spawns only 2 bags and 4 "Blooo" objects.

Do i need a timer or something ? Or should i go simply with 3 diffrent key for 3 different spawns(1 for each 2 bags) ?

local function addItems(_keyPressed)	local key = _keyPressed; -- Store the parameter in a local variable.	print(key); -- Prints the pressed key to the console.	-- We test if the correct key is pressed.	if key == 210 then		local player = getSpecificPlayer(0);    -- Java: get player one		local inv = player:getInventory();      -- Java: access player inv		-- Java: add the actual items to the inventory		inv:AddItem("icontainers.Toolbag");		inv:AddItem("icontainers.MedicalBag");		inv:AddItem("icontainers.KitchenBag");		inv:AddItem("icontainers.BookBag");		inv:AddItem("icontainers.WeaponBag");		inv:AddItem("icontainers.SupplyBag");	endend-- This will be fired whenever a key is pressed.Events.OnKeyPressed.Add(addItems);
Link to comment
Share on other sites

Ohh crap, those commas will be the end of me(this is what happens when you mess up one item and use it as basis for all the next ones). Found it.

Thx for all the help... again.

Now i need to figure out how to make all those containers stay without any actual containers in inventory. 8)

Like a default inventory, where you dont have an container item, but do get an inventory.

Link to comment
Share on other sites

Ohh crap, those commas will be the end of me(this is what happens when you mess up one item and use it as basis for all the next ones). Found it.

Thx for all the help... again.

Now i need to figure out how to make all those containers stay without any actual containers in inventory. 8)

Like a default inventory, where you dont have an container item, but do get an inventory.

For that it would probably be best if you searched the file I mentioned above for invbasic keyword and try to replicate the way that works, I don't have time to look into it myself unfortunately.

invbasic is what displays the Open Box icon in inventory UI, it's treated as a 'true' meta Container item.

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