Split from CommonAPI2 Thread (eis_os)
Is there a way to common API to grab the list of available cargos like in TPF1 for my mod?
Wir begrüßen euch in der Fan-Community zu den Spielen Transport Fever und Train Fever, den Wirtschaftssimulatoren von Urban Games. Die Community steht euch kostenlos zur Verfügung damit ihr euch über das Spiel austauschen und informieren könnt. Wir pflegen hier einen freundlichen und sachlichen Umgang untereinander und unser Team steht euch in allen Fragen gerne beiseite.
Die Registrierung und Nutzung ist selbstverständlich kostenlos.
Wir wünschen euch viel Spaß und hoffen auf rege Beteiligung.
Das Team der Transport-Fever Community
Split from CommonAPI2 Thread (eis_os)
Is there a way to common API to grab the list of available cargos like in TPF1 for my mod?
Cash, here is a list of available cargo in TPF2 by Jey_Bee :
Is it what you are looking for?
Claude I guess Cash on Wheels wants to have a script to fetch all available cargo types incl. eventuelly added types by mods.
Claude I guess Cash on Wheels wants to have a script to fetch all available cargo types incl. eventuelly added types by mods.
I'm talking about if a player is using the Expanded Industry, the mod Freestyle industry would show expanded industry cargos. If the play is using just the mail mod FSI would also show just 16 vannila cargoes + mail as an option.
I'm talking about if a player is using the Expanded Industry, the mod Freestyle industry would show expanded industry cargos. If the play is using just the mail mod FSI would also show just 16 vannila cargoes + mail as an option.
You can include an addModifier function in the runFn of your mod:
runFn = function(settings)
addModifier( "loadCargoType", cargoHandler )
end --runFn
Also define the handler:
local function cargoHandler(fileName, data)
if string.find(fileName, 'res/config') ~= 1 then
-- an addon has defined a cargo type, so do what needs doing
end
return data
end
I'm not a software engineer but this how I got into the game without a crash however it still just shows the vanilla cargoes I typed down (mod.lua) ( have 5 modifers to do)
runFn = function(settings)
game.config.industryButton = true
addModifier("loadCargoType", freight )
local function freight(fileName, data)
if string.find(fileName, 'res/config/cargo_types') ~= 1 then
end
return data
end
end
Alles anzeigen
Question is does something like this require a script? or can it just be done in the .con files?
( it needs to work with and without common API because it has been on steam for a month now. )
If this is not an easy fix I don't want waste peoples time going though a step by step instructions. I'll just update it as is.
Inline function definitions are allowed. I think you want:
runFn = function(settings)
game.config.industryButton = true
addModifier("loadCargoType",
function(fileName, data)
if string.find(fileName, 'res/config/cargo_types') ~= 1 then
end
return data
end
)
end
Alles anzeigen
Edit: This is kind of OT for this thread. If this example doesn't work for you, start a new thread and we can look for solutions.