The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on May 17, 2017, 12:34:58 PM

Title: [Gui] Button lock
Post by: Yona-TYT on May 17, 2017, 12:34:58 PM
I need to block some buttons that can break the tutorial scenario.

These are the highest priority:

Remove and Remove Now: If the vehicle is sold, it will no longer be possible to recover it.

Go to depot: If you advance step / chapter and a vehicle is sent to the warehouse, you will not be able to start it again.


Trying to solve these problems would complicate things much more, that is why blocking the buttons is the best solution.
(http://files.simutrans.com/index.php/apps/files_sharing/ajax/publicpreview.php?x=1440&y=372&a=true&file=Botones.png&t=LjaR96zRMBKbgvO&scalingup=0)
(http://files.simutrans.com/index.php/s/LjaR96zRMBKbgvO)
Title: Re: [Gui] Button lock
Post by: prissi on May 17, 2017, 11:59:04 PM
I do not like the idea to block buttons. Scripting the UI will open a new cans of worms. Moreover, the tutoial should present the real UI. And if the user click on these, you can easily find out the convoi is missing. I mean a tutorial has not to be too much restricting.
Title: Re: [Gui] Button lock
Post by: Yona-TYT on May 18, 2017, 03:05:34 AM
@Prissi
My biggest concern is that the tutorial can stagnate in one step / chapter.  :o

Quote from: gauthier on May 13, 2017, 08:23:33 AM
During the whole tutorial, player can do stuff unrelated to the tutorial and is likely to break the tutorial at any point (nobody knows how a beginner thinks :p ). Would it be possible to implement things so that a player can only do the expected action ? I mean, instead of forbiding any other actions we can think of, forbid anything that is not a precise action ? That would make coding the scenario much easier and the scenario itself will be much more resistant to bugs.
Title: Re: [Gui] Button lock
Post by: IgorEliezer on May 19, 2017, 01:09:55 PM
Quote from: Yona-TYT on May 18, 2017, 03:05:34 AM
My biggest concern is that the tutorial can stagnate in one step / chapter.  :o

Quote from: gauthierDuring the whole tutorial, player can do stuff unrelated to the tutorial and is likely to break the tutorial at any point (nobody knows how a beginner thinks :p ).
Can the player simply resume the tutorial back to the point where he got "distracted"? (Feature request?)

I usually like to explore and test things while I'm learning something. For me it's part of the learning process. We should rather help players follow the learning track (guidance) than restrain curiosity.
Title: Re: [Gui] Button lock
Post by: Yona-TYT on May 19, 2017, 07:46:17 PM

So far the only thing that can damage the scenario are the vehicles (as far as I can see).

I was thinking, do the vehicles have a unique id on the map? ... if this is true then I can use this to determine which vehicle was deleted / sold.  8)
Title: Re: [Gui] Button lock
Post by: Dwachs on May 20, 2017, 08:27:19 AM
What do you want to achieve? You could continuously loop through all convoys of the player to check whether they succeeded.

The list of convoys can be accessed with world.get_convoy_list().

You could also save the convoy_x instances and check them later:

// cnv - convoy_x instance saved somewhat earlier
try {
     cnv.get_pos() // will fail if cnv is no longer existent
     // do your checks
}
catch(ev) {
     // we are here if cnv is not longer available
}
Title: Re: [Gui] Button lock
Post by: Yona-TYT on May 20, 2017, 11:39:12 AM
Quote from: IgorEliezer on May 19, 2017, 01:09:55 PM

Can the player simply resume the tutorial back to the point where he got "distracted"? (Feature request?)
You gave me an idea, I'll try something similar. ;)
Title: Re: [Gui] Button lock
Post by: Yona-TYT on May 20, 2017, 01:30:19 PM
Quote from: Dwachs on May 20, 2017, 08:27:19 AM
What do you want to achieve? You could continuously loop through all convoys of the player to check whether they succeeded.

The list of convoys can be accessed with world.get_convoy_list().

You could also save the convoy_x instances and check them later:

// cnv - convoy_x instance saved somewhat earlier
try {
     cnv.get_pos() // will fail if cnv is no longer existent
     // do your checks
}
catch(ev) {
     // we are here if cnv is not longer available
}

At the moment it is very complicated to exclude the vehicles inside the depot, I need to count only the vehicles in circulation.  :-[
Title: Re: [Gui] Button lock
Post by: Dwachs on May 20, 2017, 04:41:08 PM
There is convoy_x::is_in_depot in r8235