Project Zomboid

Project Zomboid

Tread's Fuel Types Framework [41.65+]
 This topic has been pinned, so it's probably important
Trealak  [developer] 25 Feb, 2022 @ 1:59pm
Assign your cars custom Fuel Type (or make new Fuel Types)
Assign your cars custom fuel type

You can make such assignment in multiple ways.

First is setting up Container Content Type for your vehicles Gas Tank to Custom Fuel. It is easily done in vehicle script file, but incompatible with Vanilla. Such vehicle will not work properly without my mod (or other custom fuelling code).

Second (and maybe even easier option) is addition of simple .lua file to your mod. Code in this file will add your vehicle type to "Fuel Assignment Lists" that are used by my mod to dynamically assign fuel types. It will work only if end-user uses my mod and has Fuel Assignment Type setting set up to one that takes lists into account. If my mod is missing the vehicle will default to Vanilla Gasoline fuel.

Such file should have a filename, which in alphabetical order falls behind my file "1RS_FuelTypeAPI_VehicleSwapLists.lua". As you can see pretty much any name will do.
You can find example code (and comments explaining it) below.

--- Fuels available in my mod: "Gasoline", "Diesel", "LPG" --- Tables Index: --- 1) Ignored vehicles (always Gasoline) --- 2) Forced fuel type (always one type) --- 3) Multiple available fuel types - roll based (each instance of a car can use different fuel type [from allowed]) --- 1) Table of Vehicles ignored while Fuel Type assignment function runs (Gasoline stays no matter assignment type) --- RSFuelSwapIgnoreCars = RSFuelSwapIgnoreCars or {} --- init the table (only once per file) RSFuelSwapIgnoreCars["Base.CarLightsPolice"] = true --- add FULL car type name to the table --- 2) Table of Vehicles with forced Fuel Type while assignment function runs (assign and force ONE fuel type) --- RSForceFuelSwapCars = RSForceFuelSwapCars or {} --- init the table (only once per file) RSForceFuelSwapCars["Base.PickUpTruckMccoy"] = "Diesel" --- add FULL car type name to the table and assign existing fuel type --- 3) Table of Vehicles with multiple Fuel Types while assignment function runs --- ---Each vehicle added should keep format as in examples below. ---Sum of values per FuelType (of each vehicle) should be 100. ---Gasoline 60, Diesel 50, LPG 30 - Give 60% for Gasoline, 40% for Diesel. Each "chance" above 100 is ignored. ---Gasoline 20, Diesel 30 - Give 70% for Gasoline (requested 20 + unassigned 50) and 30% for Diesel. RSMultiFuelSwapCars = RSMultiFuelSwapCars or {} --- init the table (only once per file) RSMultiFuelSwapCars["Base.CarNormal"] = {} --- add FULL car type name to the table RSMultiFuelSwapCars["Base.CarNormal"]["Gasoline"] = 70 --- assign the car entry a fuel type and its chance RSMultiFuelSwapCars["Base.CarNormal"]["Diesel"] = 30 --- assign the car entry a fuel type and its chance


Adding own fuel types to the game

Adding own fuel types is a bit more complex. The easiest would be addition of another "liquid" fuel type, that is available on Gas Station pumps and can be stored by regular Fuel Trucks (or only in dedicated containers) etc. Fuels with custom approach (not available on stations, storeable in custom isoObjects etc.) would require extra .lua changes. Please contact me if you try to achieve such fuel.

File with code for new fuel types has to start its name on z letter. Adding regular, available "liquid" fuel can be achieved by adding it to multiple tables:
--- Table of Accepted "Fuel Types" ---- --- This table lists all accepted "content types" of containers. Any type not in this table will be ignored by my functions contentTypeTableRS = contentTypeTableRS or {} --- init the table (once per file) - REQUIRED contentTypeTableRS["YourContentType"] = true --- add content type you wish to use to the table --- Table "translating" fuel type parameter into fuel types accepted by container --- FuelTypesTableRS = FuelTypesTableRS or {} --- init the table (once per file) FuelTypesTableRS["All"]["YourContentType"] = true --- add your custom fuel to list of ALL fuel types FuelTypesTableRS["Empty"]["YourContentType"] = true --- add your custom fuel to list of fuel types accepted by regular storage tanks (and barrels) - OPTIONAL --- Without line above your fuel would be accepted ONLY by containers with content type = your fuel type. "Empty" ones will not accept it. FuelTypesTableRS["YourContentType"] = {"YourContentType"} --- REQUIRED - assign your custom content type, your custom fuel type.

Code above "creates" the fuel type readable by my functions. It can be assigned to vehicles via methods described in first part of this guide.

Game still would lack any items able to serve as "Gas Can" for this fuel type. If you wish to add them please contact me about it. It is also possible I will add instructions to this guide on a later date.