Beiträge von CARTOK

Willkommen in der Transport Fever Community

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


    Thank you! I suspected as much.


    The only way via script would be to manually try to find all possible paths to determine if there is an appropriate depot (and also find the best one). Unfortunately, above my skill level. And also not sure if it's worth the effort.


    I'm working around it by sending an existing vehicle to depot and looking for success, then capture that depot id. It's working, but causes the vehicle to be emptied, which can/does have a bad impact on profitability.

    In an updated version of my script I'm caching the depot id (and stop id) to save on this, but this also requires some error checking code to see if it works i.e. the depot still exists, and is viable - if the vehicle remains in depot after sending to a line, that's an indication that the depot is no good for a line, and I can then re-check (by sending an existing vehicle to depot) for a new depot.


    I've managed to send a request to UrbanGames (got a response!) to expand the API to avail some function to ease the depot-finding, or at least expose the clone vehicle function (which would be sufficient for my use case, "api.cmd.makeCloneVehicle" as an example). Let's see how that goes, I gather they are very busy with the upcoming update, not to mention the likely massive trove of other requests... ;-)

    Thank you! I've tested quite a bit and run at about 6-8 ms per step, so I'm well within margin. The first steps fetches the a Cargo2Entity map which takes about 30ms, but that's essentially all that is done in that step. The remaining workload I'm spreading out over several ticks, carefully limiting the amount of work done within each tick. There's a bit of overhead associated with this, but not a problem.

    I think the vehicles or lines should have a "depot" property somewhere, which is used for the default depot when cloning

    Trying to find a solution to this as time permits, can confirm that this is not correct. When "cloning" a vehicle, it finds an appropriate depot at the time. This can be tested by creating a line with a distant depot, then adding a closer depot and selecting clone on the line vehicle (it will use the new and better placed depot).


    Appreciate any suggestions on how to work on this. Looks like manual path testing is the only solution...


    Edit: Looked at the source of AutoSig2, it is way over my skill level to interpret it unfortunately. But I gather it goes to show that there should be a solution in here somewhere to manually locate an appropriate depot without relying on workarounds. Ideally, however, there would simply be a "clone" api function exposed that would handle it.

    game.interface.getEntity from a STATION_GROUP will give you "cargoWaiting" - which is used e.g. in ADvanced Statistics

    Thanks!


    I ended up using api_helper.getSimPersonsForLine(line_id) and api_helper.getSimCargosForLine(line_id), and then scan through all the entities with api.engine.getComponent(entity_id, api.type.ComponentType.SIM_ENTITY_AT_TERMINAL). Turns out that this is a pretty fast process and you can fetch hundreds of these within milliseconds.


    Actual code below:


    Apologies, writing on phone as away from computer.


    Looking for some guidance, or hint, for a sensible way to find the max CARGO or PASSENGER (SimEntities) waiting at any terminal used by line. This needs to be done for all lines.


    A brute force way is to use getSimCargoForLine (and Person equivalent), and then cycle through them to fetch the SIM_CARGO_AT_TERMINAL (or ENTITY/PERSON) component.


    This will however be rather inefficient as the same SimEntity will be applicable for many lines.


    Is it possible to, for instance, cycle through each station (foreach), and then retrieve just the SimEntities waiting at that specific station?


    The API reference is not particularly clear, and seems to be missing lots of existing functionality. Any assistance is appreciated!


    Edit: I've noticed the following function exists:


    getSimCargoAtTerminalForTransportNetwork(tnEntity)

    Obtains all cargo that is waiting at the terminal.

    Parameters:


    tnEntity Entity the entity of the transport network


    It is however unclear what tnEntity is in this instance, and how it is obtained. What constitutes an entity of the transport network? A station?

    Hi all,


    been here prior to look for some assistance as I've been digging away at my LineManager mod. Thanks to those who've assisted!


    With that said, I've now (and finally) completed a major overhaul, and figured someone here may be interested. This mod allows the automatic addition/removal of vehicles from all types of lines; PASSENGER/CARGO (even MIXED, though not recommended), ROAD/TRAM/RAIL/WATER/AIR. Sensible pre-configured rules are used to achieve this, along with a decent attempt at balance the mod workload out over time to make performance impact unnoticable/minimal. It is relatively easy to amend/create your own rules that fit your own game better by digging into the source code.


    Anyway, feel free to take a look at my GitHub repository for further information and source code: https://github.com/TommyC81/TPF2-LineManager

    Thank you!


    Yes, there is a depot property on each vehicle, this does however not seem to receive any updates as transport network changes. Perhaps what is done when cloning, it checks if it is still valid and if not another depot is found.


    Is it possible to trigger a strict "clone" command via scripting?


    Alternatively, if there's a good guide on how to interact with transport networks, stations, waiting cargo/passengers, nodes (and edges) etc. I could perhaps figure it out. I'm unfortunately at a loss at the moment.


    For reference, sample of command and associated output:

    Hi there, I've been creating a mod for automatic vehicle management on lines called "LineManager", GitHub link: https://github.com/TommyC81/TPF2-LineManager.


    One item that is critical for this mod is of course the removal and addition of vehicles. Removal is easy using:

    Code
    api.cmd.sendCommand(api.cmd.make.sellVehicle(vehicle_id))


    However, for adding vehicles, you need to specify a depot. To find a depot I've made use of the following workaround, effectively (temporarily) sending an existing vehicle to depot to see if it can find one then cancel the depot call, but use the found depot_id. Like so:

    This unfortunately empties the vehicle sent to the depot, which is less than ideal.


    Is there a better/sensible way to find a suitable (and accessible) depot for a specific line?


    I've looked at the pathfinding functions (https://transportfever2.com/wi…util.pathfinding.findPath), and believe the answer might exist in that functionality. However, this is currently beyond my knowledge and skill to implement (in particular as the associated documentation is virtually non-existent).


    Any suggestions or advice is appreciated, many thanks in advance!

    Thanks for this report! And special thanks to VacuumTube for opening the issue, and provided some insights. I should be able to fix this shortly.


    In the meanwhile, you may proceed to delete the sav.lua file or amend the entry as suggested by VacuumTube. There is no important state being saved at the moment.