Project Zomboid

Project Zomboid

Tread's Water Tank Trucks [41.65+]
 This topic has been pinned, so it's probably important
Trealak  [developer] 26 Jan, 2022 @ 11:23am
MODDING - Framework for own Water Storage vehicles
This mod can be used by other modders as framework for adding their own vehicles with water storage capability.

Any mod making use of my functions will either need this mod as requirement, or need to take over some of my code.

Making own "Water Vehicle" does not require copying my code, just set this mod as requirement. Copy and adjust code if you know what you are doing and know how to keep compatibility.


IF you decide to copy my code:
For compatibility I STRONGLY advise renaming all copied functions, templates, parts, tank content types and in-function checks (so you have to dig into .lua files). Otherwise player having multiple mods based off this code, will get repeated options in Context Menu or other gameplay issues.

I trust that people deciding to include my code directly in their mods can and will adjust it accordingly in order to keep compatibility.


Creating own Water Storage vehicle
Any vehicle assigned one of my "Water tank" parts will be able to store water and make use of my functions.
Files of interest can be found in this mods directory ".../media/scripts/vehicles". Definitions of part templates, part items and vehicles using them can be found there and used for reference.

Adding own water storage vehicle is as easy as adding one of my templates and "FuelStorage" area to the vehicle script. For example:
template = 3000WaterTruckTank, area FuelStorage { xywh = 0.0000 -2.0757 1.0811 -0.5189, }
Vehicle, which script contains this code will have my 3000 units Clean Water Tank added as its part.
Xywh parameter is used for defining zone of "water inlet", therefore defines square to which player character will go to operate the tank. Values need to be adjusted per vehicle.


Creating own Water Storage Tank parts
Editing or adding own water tanks (vehicle parts) can be done via template and part item script files. Copying and editing one of my entries should be enough.
Part template with
contentType = Water,
defines a regular Water Tank (it can have clean water and can get temporarily tainted)

Part template with
contentType = WaterTainted,
defines a Waste Water Tank (water will always be tainted)

Most of other parameters are rather self explaining. Obviously, capacity of a tank is defined in its item script via this parameter.
MaxCapacity =

To make new part addition complete it is good idea to create its fixing script. Mimicking script I added at the bottom of item defining file is a good start.


Adding vehicle tanks for new content types
Most of my code can be used to create vehicle tanks for other content types (other liquids or "drainable" game items like dry-goods[sand, gravel etc.]).

Defining a part template (and its part item) that will store different goods is very simple.
For example defining a milk storage tank could use:
contentType = ModName_milk,


On its own it does nothing. To work properly it would require mimicking/adjusting the checks in my "WaterTruckTank_ISVehicleMenu_FillPartMenu.lua".
Obviously it requires a bit of review on allowed functions and menu options. Filling inventory container or emptying the tank may suit any goods stored. On the other hand, permitting to drink propane or charcoal seems like a design mistake ;).

Templates, adjusted menu checks and addition of the part to vehicle script allow the game to assign custom menu and functions to the vehicle.

Last piece of puzzle is deciding on the functions (and items/objects) that menu options call. In case of "milk" most functions could stay as they are. Items however would have to be changed into milk ones (possibly custom items).
Some functions would need adjustments too (finding proper items in inventory, replacing item on emptying, allowing to use custom empty item, properly exchange custom empty item into filled one etc.).

More complex changes are obviously possible but probably would need completely new, custom functions written (and called from vehicle menu).

Contact
Should you have questions regarding using my mod to create your own you can try contacting me via tread.modding[at]gmail.com.

If I can, I will gladly help. Nonetheless I cannot promise anything. As I wrote I am no experienced modder, hardcore gamer and I simply might not have time or knowledge to assist.
Besides gaming and modding are just my past-times. Family, work and generally "real life" are my priorities.
Last edited by Trealak; 26 Jan, 2022 @ 11:30am