The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on February 22, 2018, 05:03:15 PM

Title: [online] Function for the clients that start.
Post by: Yona-TYT on February 22, 2018, 05:03:15 PM



I need a function similar to "function resume_game ()" and "function start ()", but only activate when a client joins a server .... something like "function client_start ()" ... is to show the scenario sale every time a player starts.

example:

function client_start()
{
  gui.open_info_win_at("goal")

  }
Title: Re: [online] Function for the clients that start.
Post by: Dwachs on February 22, 2018, 05:32:47 PM
You could use resume_game. Is this not working?
Title: Re: [online] Function for the clients that start.
Post by: jameskuyper on February 22, 2018, 05:46:09 PM
The documentation for resume_game() says "This function is called when a savegame with active scenario is loaded.". Is there a guaranteed 1 to 1 relationship between loading a save game and joining a server?
Title: Re: [online] Function for the clients that start.
Post by: Yona-TYT on February 22, 2018, 06:05:22 PM
Quote from: Dwachs on February 22, 2018, 05:32:47 PM
You could use resume_game. Is this not working?

I have tried with:gui.open_info_win_at("goal")
I'm afraid it does not work.  :-[


You can test my script here:

Title: Re: [online] Function for the clients that start.
Post by: Dwachs on February 22, 2018, 08:01:46 PM
Sorry for the wrong information: of course, any open_info_win works only locally at the server.
Title: Re: [online] Function for the clients that start.
Post by: Dwachs on February 22, 2018, 08:08:31 PM
Quote from: jameskuyper on February 22, 2018, 05:46:09 PM
Is there a guaranteed 1 to 1 relationship between loading a save game and joining a server?
In terms of the game state: yes, but not in terms of gui.
Title: Re: [online] Function for the clients that start.
Post by: Yona-TYT on February 22, 2018, 08:41:03 PM
Quote from: Dwachs on February 22, 2018, 08:01:46 PM
Sorry for the wrong information: of course, any open_info_win works only locally at the server.

Too bad, it would be good if each player could see the script rules at the moment of starting.

Edit:
Now I see it, the function is executed, but the window is shown only on the server.
Title: Re: [online] Function for the clients that start.
Post by: Yona-TYT on February 22, 2018, 09:12:22 PM
Quote from: Dwachs on February 22, 2018, 05:32:47 PM
You could use resume_game. Is this not working?

It would be good for clients to use a different function, in my humble opinion.  ;)
Title: Re: [online] Function for the clients that start.
Post by: Dwachs on February 24, 2018, 10:47:01 AM
I could modify the open_info_win function to open the window for all clients. Also somehting like open_info_win_player(player_nr) which opens the window only if clients are allowed to play with the given player/company.

One could also always open the scenario window if a savegame with scenario is loaded.

What do you think?
Title: Re: [online] Function for the clients that start.
Post by: Yona-TYT on February 25, 2018, 10:11:54 PM
Quote from: Dwachs on February 24, 2018, 10:47:01 AM
I could modify the open_info_win function to open the window for all clients. Also somehting like open_info_win_player(player_nr) which opens the window only if clients are allowed to play with the given player/company.

One could also always open the scenario window if a savegame with scenario is loaded.

What do you think?
Thank you so much  ;D ...
I like this function "open_info_win_player (player_nr)", but I would also like to indicate the tab, something like "open_info_win_player (player_nr, goal)"
Title: Re: [online] Function for the clients that start.
Post by: Dwachs on March 02, 2018, 03:13:35 PM
I added a function open_info_win_client, which does the job:

http://dwachs.github.io/simutrans-sqapi-doc/classgui.html#a407dd8f68eca07a61ddc3f5dd25391e3

also all the open_info_win functinos now open the window on server & clients.
Title: Re: [online] Function for the clients that start.
Post by: Yona-TYT on March 02, 2018, 04:51:53 PM
thank you very much !!.  ;D ;D
Title: Re: [online] Function for the clients that start.
Post by: Yona-TYT on March 03, 2018, 02:54:54 AM
It seems that something is wrong, clients do not show the scenario window.  :-[

Another detail, I noticed a lot of deicronization compared to the last time I did tests, is something causing problems ?.  ???
Title: Re: [online] Function for the clients that start.
Post by: Dwachs on March 03, 2018, 11:46:52 AM
It is only shown on clients that are connected when another joins. Should be fixed in r8395
Title: Re: [online] Function for the clients that start.
Post by: Yona-TYT on March 04, 2018, 12:16:18 PM
Quote
player_nropens scenario info window on all clients that have this player unlocked.


I thought the player number was to show scenario window only if the client is using that player. :o