Project Zomboid

Project Zomboid

JB Max Capacity Override
Players Inventory
Trying to move this out of the comments...

So I found this:
player:getInventory():hasRoomFor(player, item)
So obviously the players inventory has the hasRoomFor call.
< >
Showing 1-12 of 12 comments
So I saw your comment and did my own test and sure enough...
Player Inventory: ItemContainer:[type:none, parent:IsoPlayer{ Name:null, ID:57 }].
So ItemContainer is its class, but type is none.
Pity you can't HarmonyPatch via LUA into java classes, that would be so handy.
The java-based mod to change player inventory changes the setCapacity function and removes the very hard-capped limit of 100 on any inventory. But it does the change to the java, and this mod is all LUA, so I'm not sure where the bridge is between LUA and Java code.
So I tried this:
player:getInventory():setType("player") JB_MaxCapacityOverride.addContainer("player", 20000, false, 0)
This actually throws no errors, sets the type of the players inventory which responds to getType (tested via prints), but has no affect in the game
Last edited by Flexible Games; 6 Apr @ 1:46pm
Here's the entire section where I'm trying to get this to work:
local function setPlayerCapacity(player) local JB_MaxCapacityOverride = require("JB_MaxCapacityOverride"); player:getInventory():setType("player") print("FG Player Inventory: " .. tostring(player:getInventory())) print("FG Player Inventory Type: " .. tostring(player:getInventory():getType())) JB_MaxCapacityOverride.addContainer("player", 20000, false, 0) end local function playerCreate(playerIndex, player) setPlayerCapacity(player); end local function loadGame() local player = getPlayer(); if (player ~= nil) then setPlayerCapacity(player); end end Events.OnCreatePlayer.Add(playerCreate); Events.OnGameStart.Add(loadGame); Events.OnLoad.Add(loadGame);
The two prints produce:
FG Player Inventory: ItemContainer:[type:player, parent:IsoPlayer{ Name:null, ID:56 }].
FG Player Inventory Type: player.

No errors, no exceptions. Also no effect. :(
jbdiablo  [developer] 6 Apr @ 2:07pm 
inventory keeps the set type. I tried setting it to "crate" and no effect. Nothing should prevent you from picking up anything and everything. The biggest hurdle is the heavyload moodle which works entirely in java.

So would just need to investigate what exactly "self" is in getCapacity() and getEffectiveCapacity(). There probably isn't anything preventing this, though. I'll have a look at it tomorrow if I have time.
I will look forward to any future LUA wizardry.
So I found one bug that has me stumped.
I set up addContainer on fridge type, and the fridge does reflect the increased amount...
the freezer does not.

Furthermore, some freezer types do NOT have a container = type set in the tile file I mentioned before.
An example is appliances_refrigeration_01_48
I have one in my base, its a freezer but has no container type set
and has FreezerCapacity = 30

How can it have capacity, but no container = value?
And why does the change to fridge not also affect the freezer?
jbdiablo  [developer] 7 Apr @ 10:46am 
I'll look in to it. I know that the stand alone freezers work fine. I thought the fridge-freezers did too.
jbdiablo  [developer] 7 Apr @ 1:21pm 
just checked and freezer is working.

JB_MaxCapacityOverride.addContainer("freezer", 250, false)
\o/ going to make that 'freezer' edit to the script now.

I have to remove microwave as it seems to have broken the functionality of the thing, you turn it on, and it turns itself off right away.

And it's so odd that my attempt at setting the 'player' inventory type didn't take. :(
jbdiablo  [developer] 7 Apr @ 8:21pm 
I haven't looked at what's changed in 42.7. I don't think anything I did would change the way this works, especially with microwaves in particular.

As far as player inventory, I did a half-ass attempt and even though player inventory is an ItemContainer and my functions are called in lua, the java code might be getting in the way.
I've been trying to track down what is causing my equipped weapons/tools from losing all condition/durability when I load a save. A nearly fresh tool or weapon is just dead for no reason I've been able to find. Super frustrating.

Anyway, can confirm the microwave still glitches out and turns off without the change to its inventory from this script. So must be a base-game bug?
jbdiablo  [developer] 8 Apr @ 12:05pm 
yea, a quick search on the PZ discord and it looks like it's an issue
< >
Showing 1-12 of 12 comments
Per page: 1530 50