Author Topic: Scenarios for online games  (Read 7598 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

Scenarios for online games
« on: May 08, 2016, 02:02:56 PM »
Scenarios for online gamesI do not know if this is possible, but it would be good to use scenaros for change the rules of game in online mode.I would like to make this a scenario: http://forum.simutrans.com/index.php?topic=9898.msg93647#msg93647

Upedate:

Scenario: regions-v4.3.zip (Using r7880.)



The changes are:


- Shared regions is now easier, you only need to place a label text to share region, the coordinates are obtained using remover tool.
- Now the region is shared in the info is displayed.

Test In: Rive's Server http://forum.simutrans.com/index.php?topic=14806.msg146173#msg146173
« Last Edit: September 18, 2016, 07:49:44 PM by Yona-TYT »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8764
  • Total likes: 307
  • Helpful: 229
  • Languages: De,EN,JP
Re: Scenarios for online games
« Reply #1 on: May 08, 2016, 08:27:29 PM »
There is a patch for AI players. I am not sure if the API is more restricted for such scripts. But if not, just attach an AI to a player (maybe even player one) could achieve this too.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #2 on: May 09, 2016, 06:49:53 AM »
Your idea is certainly possible with scripting, also for online games. Needs some work, though.

-----

Here is a script that can be used for online games:

https://github.com/Dwachs/simutrans-scenarios/tree/master/pak/scenario/achieve

Each player earns point for certain activities / achievements. I do not know, whether it still works.
Parsley, sage, rosemary, and maggikraut.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8764
  • Total likes: 307
  • Helpful: 229
  • Languages: De,EN,JP
Re: Scenarios for online games
« Reply #3 on: May 09, 2016, 09:58:14 PM »
Somehow these scripts need to be downloaded with the savegame to each player, or do we have this already?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #4 on: May 10, 2016, 05:57:36 AM »
No, this script solely runs at the server. No need for downloads to clients.
Parsley, sage, rosemary, and maggikraut.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8764
  • Total likes: 307
  • Helpful: 229
  • Languages: De,EN,JP
Re: Scenarios for online games
« Reply #5 on: May 10, 2016, 09:24:38 PM »
But how do you forbid to built something on the client (like those borders)? The action will work on the client, the server forbid it, desync? In that case the script would need to god with the savegame, or?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #6 on: May 11, 2016, 06:19:43 AM »
This is entirely possible without desyncs. One can restrict way building by specifying regions that are forbidden for certain players: These regions are broadcasted to the clients, and the client wills will respect these regions in the way building pathfinder.

The api commands that control these regions are here

http://dwachs.github.io/simutrans-sqapi-doc/classrules.html
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #7 on: May 11, 2016, 09:42:59 AM »

I think it would be good to create a test server for this, do not you think ?.  ;)

Offline Yona-TYT

Re: Scenarios for online games
« Reply #8 on: May 29, 2016, 08:37:08 AM »
This is entirely possible without desyncs. One can restrict way building by specifying regions that are forbidden for certain players: These regions are broadcasted to the clients, and the client wills will respect these regions in the way building pathfinder.


The api commands that control these regions are here


http://dwachs.github.io/simutrans-sqapi-doc/classrules.html


For some reason the function "rules.for id_way_tool_rect" does not work in your scenario. ???



Edit
Increase in the number of player (player_nr) is not working as it should.  ??? 
I need to exclude a player but somehow  adds it all.
Code: [Select]
yona_cuadro <- [
   {x=179, y=108},
   {x=191, y=100},


]


tools <- [tool_build_bridge, tool_build_tunnel, tool_raise_land, tool_setslope, tool_remover ]
error <- "Esta region pertenece a otro jugador  "


function forbid_tools()
{   
   
   for(local j=0; j<tools.len(); j++) {
         for(local i=0; i<yona_cuadro.len()-1; i++) {
                 
               local player=0
   
               for(local p=0; p<16; p++) {
                           
                        if   (p != player)  rules.forbid_way_tool_rect(p, tools[j], wt_all, yona_cuadro[i], yona_cuadro[i+1], ttext(error + player_x(player).get_name()))
                 
                     }


               }
         }
         
}
« Last Edit: May 29, 2016, 02:35:44 PM by Yona-TYT »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #9 on: May 30, 2016, 06:38:02 AM »
What do you want to achieve with this code? As it is written, it should forbid the region for all players except player 0 (the first player).
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #10 on: May 30, 2016, 07:21:26 AM »

What I want to achieve is that the area is accessible only to a player, but this is not fulfilled with my code. ???


the other is that "rules.forbid_way_tool_rect" seems to be incompatible with its Scenario online games.


Remember that my goal is to make a map divided into regions. ;)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #11 on: May 30, 2016, 11:24:15 AM »
Please upload the complete script file.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #12 on: May 31, 2016, 02:28:46 AM »

I could already solve, I had exceeded the number of players that was the whole problem. ;)


I created a list of coordinates to the respective rectangles, but does not work correctly in server mode.


I would also like to draw lines at the edges of the rectacgulos to indicate the boundaries of each region, that would be very nice.


To test a map of 512x512 is needed.


Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #13 on: May 31, 2016, 06:01:01 AM »
I could already solve, I had exceeded the number of players that was the whole problem. ;)
Player index is from 0 to 14, 1 is public player. Number 15 has special meanings: it means ownerless stuff, or for to forbid tools can be used to mean 'all players'.
Quote
I created a list of coordinates to the respective rectangles, but does not work correctly in server mode.
What does not work?

Drawing something is not implemented. You could place text markers at the corners of the rectangle.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #14 on: May 31, 2016, 08:39:42 AM »

Quote
What does not work?
In a local game works fine, but when it comes to a client in online mode, the link sends it to another party ... how can I correct this?



Quote
Drawing something is not implemented. You could place text markers at the corners of the rectangle.
It can be done automatically, as?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #15 on: May 31, 2016, 12:50:59 PM »
There should be no difference when viewing these texts on client and servers (only maybe some time delay).
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #16 on: June 01, 2016, 04:43:29 AM »
There should be no difference when viewing these texts on client and servers (only maybe some time delay).
Resolved, thanks.

now I need to know how to restrict the use of tools climatica edition.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #17 on: June 02, 2016, 09:06:26 AM »

This almost completed ... Still are lacking restrict the use of editing tools climate and mark the limits of the regions (would be good to see this on the mini map).
In my tests I found some errore in the script when players are activated.


Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #18 on: June 02, 2016, 12:15:03 PM »
Still are lacking restrict the use of editing tools climate
In r7805 there will be new constants  tool_change_water_height, tool_set_climate to catch this.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #19 on: June 02, 2016, 07:31:33 PM »

In r7805 there will be new constants  tool_change_water_height, tool_set_climate to catch this.
thanks. ;D





Something like this: minimap_rect(coord, coord, name)





« Last Edit: June 03, 2016, 07:13:25 AM by Yona-TYT »

Offline Yona-TYT

Re: Scenarios for online games
« Reply #20 on: June 04, 2016, 05:03:16 PM »

One of the problems that exist in the online games are public stations, because they can be created but not deleted. We need a function that allows to eliminate the public service stations.
And because the map is divided in regions, public stations are much needed here.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #21 on: July 16, 2016, 11:23:56 PM »
The script is taking too long to load, using the latest revisions.  ???



Offline DrSuperGood

Re: Scenarios for online games
« Reply #22 on: July 17, 2016, 04:52:28 AM »
There were some changes to the scripting engine recently. I am guessing one of them broke it.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #23 on: July 17, 2016, 03:40:08 PM »
Could you please upload the recent version of your script? Attachments are broken currently.

Edit: please try with r7853
« Last Edit: July 17, 2016, 04:48:27 PM by Dwachs »
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #24 on: July 19, 2016, 07:40:28 PM »
Could you please upload the recent version of your script? Attachments are broken currently.

Edit: please try with r7853
Works fine ... thanks !!

Offline Yona-TYT

Re: Scenarios for online games
« Reply #25 on: August 11, 2016, 02:35:19 PM »
This error occurs when active new players.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #26 on: August 11, 2016, 03:56:19 PM »
This is a bug in the script you copied from my scenario. It should work if you replace (lines 472++)
Code: [Select]
local player = player_x(pl)
if (pl != 1  &&  player.is_active()) {
st.append( clone active_players[pl] )
}
by
Code: [Select]
if (pl != 1  &&  active_players[pl]) {
st.append( clone active_players[pl] )
}

Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #27 on: August 23, 2016, 02:53:50 PM »
@Dwachs
is there a way to get size of the map? ???

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #28 on: August 26, 2016, 04:45:39 PM »
not yet, unfortunately.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #29 on: August 26, 2016, 05:24:40 PM »

Offline Yona-TYT

Re: Scenarios for online games
« Reply #30 on: August 27, 2016, 12:41:25 PM »
@Dwachs
A small detail, I would like to see the scenario information window after loading the server. It does not seem to be somewhat difficult to implement.

Offline River

Re: Scenarios for online games
« Reply #31 on: August 28, 2016, 12:51:24 AM »
isn't this show at menu -> scenario info? or are you looking for the debug information?

Offline Yona-TYT

Re: Scenarios for online games
« Reply #32 on: August 28, 2016, 01:18:49 AM »

isn't this show at menu -> scenario info? or are you looking for the debug information?
I mean automatically display the info window when you load the game. Like when a scenario is loaded locally, the first thing that appears is the info window.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #33 on: August 28, 2016, 02:54:52 PM »
you could call gui.open_info_window() in resume_game. Does this work?
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #34 on: August 28, 2016, 04:06:24 PM »
you could call gui.open_info_window() in resume_game. Does this work?
Not on the servers I'm afraid.





By the way, "gui.open_info_win ()" always shows the "Progress" tab, I would like to choose the tab to show.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #35 on: September 11, 2016, 04:11:02 PM »
@Dwachs
Something is restricting the tool "found a new city" for the players but I can not find the cause ... maybe an error ?.
regions2-pak64-1024x1024v3.0_.zip

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #36 on: September 11, 2016, 04:15:25 PM »
@Dwachs
is there a way to get size of the map? ???
yes, from r7863 on: world.get_size()



@Dwachs
Something is restricting the tool "found a new city" for the players but I can not find the cause ... maybe an error ?.
regions2-pak64-1024x1024v3.0_.zip
Please report each new issue in its own thread from now on. It is really hard to follow all that different bug reports and extension requests.
« Last Edit: September 11, 2016, 04:26:36 PM by Isaac.Eiland-Hall »
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #37 on: September 11, 2016, 04:19:55 PM »
yes, from r7863 on: world.get_size()
Thank you !.


Please report each new issue in its own thread from now on. It is really hard to follow all that different bug reports and extension requests.
OK I understand .




Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #38 on: September 11, 2016, 04:21:26 PM »
@Dwachs
Something is restricting the tool "found a new city" for the players but I can not find the cause ... maybe an error ?.
regions2-pak64-1024x1024v3.0_.zip
This is the default implementation of is_tool_allowed in script/scenario_base.nut. You have to implement this function yourself to overwrite the default behavior.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #39 on: September 11, 2016, 04:37:10 PM »
Resolved, thanks.  ;D

Offline Yona-TYT

Re: Scenarios for online games
« Reply #40 on: September 16, 2016, 12:32:07 PM »
Upedate:

Scenario: regions-v4.0.zip



The changes are:

- You can configure regions using the public service
- Delete stations is now easier to use, only you need remover tool.
- It's not possible to remove oil platforms. XD


Test In: Rive's Server http://forum.simutrans.com/index.php?topic=14806.msg146173#msg146173


« Last Edit: September 17, 2016, 12:44:42 PM by Yona-TYT »

Offline Yona-TYT

Re: Scenarios for online games
« Reply #41 on: September 18, 2016, 07:44:34 PM »
Upedate:
Scenario: regions-v4.3.zip (Using r7880.)
It is recommended to use r7880 for this: http://forum.simutrans.com/index.php?topic=15748.msg154484#msg154484 ;)

 The changes are:
- Shared regions is now easier, you only need to place a label text to share region, the coordinates are obtained using remover tool.
- Now the region is shared in the info is displayed.

Test In: Rive's Server http://forum.simutrans.com/index.php?topic=14806.msg146173#msg146173


« Last Edit: September 18, 2016, 07:56:39 PM by Yona-TYT »

Offline Yona-TYT

Re: Scenarios for online games
« Reply #42 on: September 19, 2016, 04:34:23 AM »
@River, I will add connections rails and powerlines (it works now), what do you think this ?.






Offline River

Re: Scenarios for online games
« Reply #43 on: September 19, 2016, 12:25:40 PM »
all it does is remove the requirement to share the end of your lines. its a nice added thing but not very important if you ask me.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #44 on: September 20, 2016, 12:49:33 AM »

It would be nice explains this with pictures, but the patch still not incorporated...http://forum.simutrans.com/index.php?topic=15049.0
Though not if work in online mode. ???

Offline Yona-TYT

Re: Scenarios for online games
« Reply #45 on: October 23, 2016, 04:23:07 PM »

@Dwachs
River encountered an error from your server: http://forum.simutrans.com/index.php?topic=14806.msg155358#msg155358
Scenario: regions-4.7-test.zip
It seems that something broke in one of the last nights, now this error:

It does not seem to be a problem with the script. ???


Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4235
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Scenarios for online games
« Reply #46 on: October 23, 2016, 05:59:38 PM »
I fixed it in  my script:

https://github.com/Dwachs/simutrans-scenarios/blob/master/pak/scenario/achieve/scenario.nut

It was there from the beginning. There were no recent changes that could have triggered the error. Just bad luck :)
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Scenarios for online games
« Reply #47 on: October 23, 2016, 07:54:14 PM »

It is strange that this has never been seen. :o 
Thank you so much. :thumbsup: 
« Last Edit: October 23, 2016, 08:17:43 PM by Yona-TYT »