Project Zomboid

Project Zomboid

JB Max Capacity Override
80 Comments
neobenmike 15 Aug @ 10:56pm 
No worries, already got it working, thanks
jbdiablo  [author] 15 Aug @ 8:33pm 
@neobenmike - which version of 42 are you running?
neobenmike 15 Aug @ 6:11pm 
Can't enable mod due to requirement typo: \StarlitLibrary instead of just StarlitLibrary
jbdiablo  [author] 31 Jul @ 10:58am 
Re-uploaded the mod data enhancement. See description on how to use it and the limitations.

Thank you Eizen for the inspiration and testing!
jbdiablo  [author] 30 Jul @ 7:57am 
no worries, go ahead and hit me up on discord @jimbeamdiablo
Eizen 30 Jul @ 4:16am 
@jbdiablo thank you for all the help. I managed to solve my issue except when equipping the backpack the capacity reverts back. Can I message you in discord? Btw I saw the thread in the discord link that you gave me. I'm really sorry for the clutter that I made in your comment section
jbdiablo  [author] 29 Jul @ 5:05pm 
I broke it. Reverting until I can figure it out
jbdiablo  [author] 29 Jul @ 2:56pm 
Added a mod data capacity override for single containers. To use:

yourContainer:getModData()["JB_MaxCapacityOverride"] = { capacity = 75 }

It still checks if your container type is in the lookup table first. Let me know if there are any issues with it. Cheers!
jbdiablo  [author] 29 Jul @ 12:13pm 
@Eizen - I don't know what you're cooking but I tested and mod data was persistent on the item. I'll mess around with my code in a bit to check for mod data when patching capacities.
jbdiablo  [author] 29 Jul @ 11:34am 
I was trying to find a work around to preserve mod data, because that's messed up.
Eizen 29 Jul @ 11:23am 
Damn, alright. I'm currently working on a solution that I theorized
jbdiablo  [author] 29 Jul @ 10:46am 
or not - "if your backpack has context menu wear options, it will nuke all the mod data on switch"
jbdiablo  [author] 29 Jul @ 9:58am 
@Eizen - I think the consensus is that mod data would be the way to go
jbdiablo  [author] 29 Jul @ 9:52am 
@Eizen - I asked about this in the PZ mod_development discord and the answer was "Tell them to come here and ask about it" :)

https://discord.gg/theindiestone
Eizen 29 Jul @ 9:22am 
Yes, I've tried that but the type reverts back to original when you relog :(
jbdiablo  [author] 29 Jul @ 9:20am 
@Eizen - oh yea, that's a wrench in the cog for sure. Can you setType to something unique when it's upgraded?
Eizen 29 Jul @ 9:15am 
Hmmm this is tricky, I have a mod that adds a functionality to upgrade a bag and increase its capacity, using JB_MaxCapacityOverride.CONTAINERS_TO_OVERRIDE causes all bags to increase capacity. Maybe it's impossible for now. Anyways, thank you
jbdiablo  [author] 29 Jul @ 9:00am 
@Eizen - you should be able to change the value for the container in the lookup table, like:

JB_MaxCapacityOverride.CONTAINERS_TO_OVERRIDE["Bag_ShotgunDblSawnoffBag"].capacity = 100

it works in my head anyway, I haven't tried it.
Eizen 29 Jul @ 2:55am 
After I called this JB_MaxCapacityOverride.addContainer("Bag_ShotgunDblSawnoffBag", 125, true) , is it not possible to programmatically change the capacity to 100? like this container:setCapacity(100)
jbdiablo  [author] 26 Jun @ 8:09am 
@Briar Feet require=\StarlitLibrary is correct for B42
Matikanetannhauser 25 Jun @ 6:41pm 
@jbdiablo the issue is about the mod requirements. On the mod.info it was written like this: require=\StarlitLibrary and the correct one should be like this: require=StarlitLibrary because that is the mod id of Starlit Library. Ty!
jbdiablo  [author] 16 Jun @ 4:18pm 
@Vengent thanks for the info!

@Promises this is for 42. changing capacities in 41 was so easy and didn't need any of *waves hands* this
Subway Shark 16 Jun @ 3:30pm 
im using it on b41
Vengent 16 Jun @ 3:15pm 
I've got it working in 42.9 with crates and some other movable containers. I'm not seeing any error about starlit currently.
jbdiablo  [author] 16 Jun @ 2:37pm 
@Promises @Luna - I'll do some digging tomorrow. I haven't even fired up PZ since 42.9 so something may have changed.
Luna ~ 14 Jun @ 7:51pm 
same problem as person below
Subway Shark 14 Jun @ 7:25pm 
i have starlit library but in the mod menu it wont let me enable this because it says i dont have the library
jbdiablo  [author] 9 Jun @ 10:36am 
@Vengent I believe "crate" is the type you need"

-- Only using (containerType, capacity, preventNesting)
local JB_MaxCapacityOverride = require("JB_MaxCapacityOverride")
JB_MaxCapacityOverride.addContainer("crate", 500, false)
Vengent 6 Jun @ 6:06pm 
Hey JB, any chance of adding some samples for using this with containers like crates? Found a good one for character bags, but nothing for container existing in the world.
Flexible Games 27 May @ 7:32pm 
I was hoping for some built-in flag or something that skips inventory as mass, but I should have known better with this game.
jbdiablo  [author] 27 May @ 3:54pm 
If you want to dig around in the CarController java, there might be a work-around without too much fuss. Like changing the vehicle mass in the vehicle script, maybe.
Flexible Games 27 May @ 1:29pm 
I can confirm that a trailer with over ~1800 weight does not move. Got it set to 20k, put about 2400 in planks and logs into it, would not budge. I could back it up, funny enough, but going forward it was like it was anchored to the ground. Had to empty it down to about 1800 for it to work.
jbdiablo  [author] 27 May @ 8:44am 
I get it - some days I write succinct, neat code and other days I struggle with simple things.

"TruckBed" is vanilla. You could probably setType() if vehicle = W900 and then set capacity to what you want. That way you don't change every TruckBed. I don't see why the W900 mod would care what the container type is named, but I could be wrong.
Flexible Games 26 May @ 8:12pm 
I'm barely hanging on with all this LUA.
Was looking at the W900 truck mod to customize it. It uses "TruckBed" as well and I am afraid to mess too much with renaming things as all the data is tied up in knots together.

The other things I desperately want to do is make the W900's vehicle transport flatbed able to take more than one vehicle. Sort of like how you can load many chickens into an animal trailer. But again, more LUA that I have no idea how to do.
jbdiablo  [author] 26 May @ 3:31pm 
This is what I used in testing and it didn't affect the vehicle handling:

JB_MaxCapacityOverride.addContainer("TruckBedOpen", 500, false)
JB_MaxCapacityOverride.addContainer("TruckBed", 500, false)

I believe I had it up to 10,000 at some point and it was fine. You could loop through vehicle parts and check if they are a container. I believe vanilla does this somewhere. Seats, glovebox, begins with "TruckBed" are all going to be containers, though. It should be seamless.

Also, if you give the player container a type, you can alter the capacity. The big issue I couldn't overcome without java modding is - the over loaded moodle won't go away.
Flexible Games 26 May @ 2:42pm 
I was poking around a bit to try and find the container types used for vehicle trunk and storage to see if I could increase those with this mod. No luck so far, but it did occur to me that if I have 10k weight of stuff in a trunk the car might not be able to move.
So now I think I might have to override something somewhere regarding vehicle weight calculations.
Sigh...
jbdiablo  [author] 1 May @ 2:21pm 
@LUCAQUANTUM This mod is for Build 42. There isn't any reason to use this with 41 as the capacity limitations aren't present in that build.
QUANTUMSTAR 30 Apr @ 5:18pm 
Hi, i'm on 41 build and just wanted to inform that I'm experiencing the same problem as landerv123. I have Starlit Library active, I didn't get it from a modpack, downloaded it off the workshop. Still this mod won't activate with an error msg saying \StarlitLibrary isn't installed.
Flexible Games 22 Apr @ 7:00pm 
I'm talking about Build 42. Yes someone made a mod that enables multiplayer.
Been trying to get it to work, I can connect with mods, but a friend is having issues.
jbdiablo  [author] 22 Apr @ 3:53pm 
Does ISInventoryTransferAction exist in 41? Also, in 41 it's as easy as using setCapacity() on the container.
Flexible Games 22 Apr @ 1:59pm 
So as a tentative test, I've wrapped any client-side code in a simple if isClient() then block
time will tell
Flexible Games 22 Apr @ 1:34pm 
So I've been trying to get this to work with Multiplayer, yes, it does exist
but for some reason I'm getting a ton of LUA script errors like this:
function: JB_MaxCapacityOverride.lua -- file: JB_MaxCapacityOverride.lua line # 315 | MOD: JB Max Capacity Override
Callframe at: require
function: SetContainerSize -- file: infinitecontainers.lua line # 64 | MOD: Infinite Carryable Containers

[15:25:12] [INFO] [Zomboid/Error]: ExceptionLogger.logException> Exception thrown
java.lang.RuntimeException: attempted index: new of non-table: null at KahluaThread.tableget(KahluaThread.java:1667).

The line in question?
local OG_ISInventoryTransferAction_new = ISInventoryTransferAction.new

I'm trying to get this to work, but I may have to abandon it as the server seems obsessed with running client side scripts
jbdiablo  [author] 11 Apr @ 8:05pm 
Updated so there's no more loooooooog floats. Thanks Skimble Shanks! I didn't really get anything else done on it this week. Cheers!
jbdiablo  [author] 11 Apr @ 9:45am 
@landerv123 -- you're on build 42? You're not using a modpacked StarLit Library?
landerv123 11 Apr @ 4:33am 
it says it needs '/starlitlibery' but i already have that mod active and it still doesnt want to let this mod eneable.
Skimble Shanks 8 Apr @ 9:27am 
thanks for your work!

and btw reading ur codes is fun LOL

i'm sorry i didn't submit a PR directly, i didn't notice you pasted github link at the bottom of description
jbdiablo  [author] 7 Apr @ 10:44am 
@Skimble Shanks - my bad, I don't think I ever noticed that. Thanks!
Skimble Shanks 7 Apr @ 9:47am 
please allow me to suggest using `return math.ceil(effinCapacity * 1.3)` in line 173 instead, to avoid a loooooooog float like 150.7000000002 making UI ugly
jbdiablo  [author] 6 Apr @ 8:15pm 
@Flexible Games - lol yea, I got rid of the item type check before adding to the container table and added a script check before the DoParam since it would throw an error if the script didn't exist. No sense in clogging up the debug logs.
Flexible Games 6 Apr @ 8:00pm 
I like how in the same patchnotes you have add "if containerType exists" AND got rid of "if container type exists" in the same function :D