The International Simutrans Forum

 

Author Topic: [online] Function for the clients that start.  (Read 1946 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1171
    • Simutrans-BLOG
  • Languages: ES
[online] Function for the clients that start.
« 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:

Code: [Select]
function client_start()
{
  gui.open_info_win_at("goal")

  }

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4530
  • Languages: EN, DE, AT
Re: [online] Function for the clients that start.
« Reply #1 on: February 22, 2018, 05:32:47 PM »
You could use resume_game. Is this not working?

Offline jameskuyper

  • *
  • Posts: 78
  • Languages: en
Re: [online] Function for the clients that start.
« Reply #2 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?

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1171
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Function for the clients that start.
« Reply #3 on: February 22, 2018, 06:05:22 PM »
You could use resume_game. Is this not working?

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


You can test my script here:

 

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4530
  • Languages: EN, DE, AT
Re: [online] Function for the clients that start.
« Reply #4 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4530
  • Languages: EN, DE, AT
Re: [online] Function for the clients that start.
« Reply #5 on: February 22, 2018, 08:08:31 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1171
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Function for the clients that start.
« Reply #6 on: February 22, 2018, 08:41:03 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.
« Last Edit: February 22, 2018, 09:08:57 PM by Yona-TYT »

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1171
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Function for the clients that start.
« Reply #7 on: February 22, 2018, 09:12:22 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.  ;)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4530
  • Languages: EN, DE, AT
Re: [online] Function for the clients that start.
« Reply #8 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?

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1171
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Function for the clients that start.
« Reply #9 on: February 25, 2018, 10:11:54 PM »
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)"

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4530
  • Languages: EN, DE, AT
Re: [online] Function for the clients that start.
« Reply #10 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1171
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Function for the clients that start.
« Reply #11 on: March 02, 2018, 04:51:53 PM »
thank you very much !!.  ;D ;D

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1171
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Function for the clients that start.
« Reply #12 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 ?.  ???

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4530
  • Languages: EN, DE, AT
Re: [online] Function for the clients that start.
« Reply #13 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

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1171
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Function for the clients that start.
« Reply #14 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