A Steam user with the handle mav12222 created a mod to implement mail as a cargo. He added the ability to carry mail to only a limited number of vehicles. This is how I added mail as a cargo type to anything that carrys goods. You could probably use it as a model to change capacities:
Code
local function addCargo(fileName, data, cargotypes, capacity)
if data.metadata.transportVehicle.compartmentsList ~= nil then
local comp = data.metadata.transportVehicle.compartmentsList
for i = 1, #comp do
local cap = capacity or comp[i].loadConfigs[1].cargoEntries[1].capacity
local cargoBay = comp[i].loadConfigs[1].cargoEntries[1].cargoBay
-- comp[i] = { loadConfigs = {} }
local c = comp[i]
for j = 1, #cargotypes do
table.insert(c.loadConfigs, { cargoEntries = { { type = cargotypes[j], cargoBay = cargoBay, capacity = cap } } })
end
end
else
local comp = data.metadata.transportVehicle.compartments
for i = 1, #comp do
local cap = capacity or comp[i][1][1].capacity
local cargoBay = comp[i][1][1].cargoBay
-- comp[i] = { }
local c = comp[i]
for j = 1, #cargotypes do
c[#c + 1] = { { type = cargotypes[j], cargoBay = cargoBay, capacity = cap } }
end
end
end
end
local mail = {"MAIL"}
local function checkCompartments(data)
if type(data) == 'string' and data == 'GOODS' then return true end
if type(data) ~= 'table' then return false end
for j = 1, #data do
if data[j].type ~= nil and data[j].type == 'GOODS' then return true end
if type(data[j]) == 'table' and checkCompartments(data[j]) then return true end
end
return false
end
local function checkGoods(data)
if data.metadata == nil then return false end
if data.metadata.transportVehicle == nil then return false end
if data.metadata.transportVehicle.compartmentsList ~= nil then
local comp = data.metadata.transportVehicle.compartmentsList
for i = 1,#comp do
for j = 1,#comp[i].loadConfigs do
for k = 1,#comp[i].loadConfigs[j].cargoEntries do
if comp[i].loadConfigs[j].cargoEntries[k].type == 'GOODS' then return true end
end
end
end
else
local comp = data.metadata.transportVehicle.compartments
return checkCompartments(comp)
end
return false
end
local function metadataHandler(fileName, data)
if not data.metadata then return data end
if not data.metadata.transportVehicle then return data end
if checkGoods(data) then addCargo(fileName, data, {'MAIL'}) end
return data
end
function data()
return {
info = {
minorVersion = 0,
severityAdd = "NONE",
severityRemove = "NONE",
name = _("WIP: Mail Mod"),
description = _("This is a experimental mod that adds Mail cargo that is demanded by Residential zones. Includes a mail truck using he studebaker model from 1940 onwards. NOTE: due to lazyness on my part only boxcars, the first hore-drawn wagon, the first steam lorry in each vehicle region and the mail truck can carry mail (no ships/planes)."),
tags = {"Misc", "Script Mod", "Truck" },
visible = true,
},
runFn = function(settings)
addModifier( "loadModel", metadataHandler )
end --runFn,
}
end
Alles anzeigen