News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

A function is_convoy_delete(pl, convoy) is needed for the tutorial

Started by Yona-TYT, December 16, 2022, 10:09:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT


I suggested this a long time ago to solve the problems with eliminated vehicles, but it was decided to use a iteration to the list of all the vehicles to know if they were on the map or not.

Lately I have had problems with this logic and in some cases it has taken me days to solve the failures, it is very tedious to maintain this!. (https://forum.simutrans.com/index.php/topic,20760.msg202539/topicseen.html#msg202539)

I would like to propose again this function "is_convoy_delete(pl, convoy) " called from the [delete convoy] button and thus solve these problems definitively.

I can make a patch myself if you agree.  ;)

Andarix

You can test whether a convoy exists or not with the following function.
cnv corresponds to the convoy object

cnv.is_valid()

Yona-TYT

Quote from: Andarix on December 16, 2022, 10:31:14 PMYou can test whether a convoy exists or not with the following function.
cnv corresponds to the convoy object

cnv.is_valid()

Validating whether the convoy exists is not the problem, the real problem is the entire detection and action lodge.

For example:

If you're in Chapter 5 and you delete a convoy from Chapter 2, then you'll go back to Chapter 2 and have to reconfigure exactly that vehicle.

This process requires a constant analysis of the vehicles in circulation and that is the problem, many errors can occur in the process and solving them can be tedious at times.

In some cases starting vehicles can cause inconsistencies in the counters, also cause problems if they are started using automated commands.

Another problem is that the performance of the script suffers due to the constant iteration of the vehicle list plus a lot of conditional statements to make the logic work through it all.

Dwachs

This seems to be more a problem with the logic in the script. Why should one replay Chapter 2? It is not necessary. If the current chapter requires a convoy to exist, then the player has to buy it again after deleting.

Such a callback function would not be very informative. It can send a convoy id, but if the call is processed in the script the convoy might already be invalid, and its data cannot be accessed anymore.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

I just need to prevent the use of the [ Remove Now ] button for some specific convoys.

Yona-TYT

Quote from: Andarix on December 16, 2022, 10:31:14 PMYou can test whether a convoy exists or not with the following function.
cnv corresponds to the convoy object

cnv.is_valid()
If the convoy doesn't exist then this will fail, I can only "try" "catch"

Captura desde 2022-12-18 08-26-29.png

Andarix

Sorry, I don't understand what the function is supposed to be good for.

function checks_convoy_removed(pl)

Yona-TYT