News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Scenarios for online games

Started by Yona-TYT, May 08, 2016, 02:02:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

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

prissi

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.

Dwachs

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.

prissi

Somehow these scripts need to be downloaded with the savegame to each player, or do we have this already?

Dwachs

No, this script solely runs at the server. No need for downloads to clients.
Parsley, sage, rosemary, and maggikraut.

prissi

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?

Dwachs

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.

Yona-TYT


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

Yona-TYT

#8
Quote from: Dwachs 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


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.

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()))
                 
                     }


               }
         }
         
}

Dwachs

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.

Yona-TYT


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. ;)

Dwachs

Please upload the complete script file.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT


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.


Dwachs

Quote from: Yona-TYT on May 31, 2016, 02:28:46 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.

Yona-TYT


QuoteWhat 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?



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

Dwachs

There should be no difference when viewing these texts on client and servers (only maybe some time delay).
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs 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).
Resolved, thanks.

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

Yona-TYT


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.


Dwachs

Quote from: Yona-TYT on June 02, 2016, 09:06:26 AM
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.

Yona-TYT

#19
Quote from: Dwachs on June 02, 2016, 12:15:03 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)






Yona-TYT


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.

Yona-TYT

The script is taking too long to load, using the latest revisions.  ???



DrSuperGood

There were some changes to the scripting engine recently. I am guessing one of them broke it.

Dwachs

#23
Could you please upload the recent version of your script? Attachments are broken currently.

Edit: please try with r7853
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs 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
Works fine ... thanks !!

Yona-TYT

This error occurs when active new players.

Dwachs

This is a bug in the script you copied from my scenario. It should work if you replace (lines 472++)

local player = player_x(pl)
if (pl != 1  &&  player.is_active()) {
st.append( clone active_players[pl] )
}

by

if (pl != 1  &&  active_players[pl]) {
st.append( clone active_players[pl] )
}


Parsley, sage, rosemary, and maggikraut.

Yona-TYT

@Dwachs
is there a way to get size of the map? ???

Dwachs

Parsley, sage, rosemary, and maggikraut.


Yona-TYT

@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.

River

isn't this show at menu -> scenario info? or are you looking for the debug information?

Yona-TYT


Quote from: River on August 28, 2016, 12:51:24 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.

Dwachs

you could call gui.open_info_window() in resume_game. Does this work?
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on August 28, 2016, 02:54:52 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.

Yona-TYT

@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

Dwachs

#36
Quote from: Yona-TYT on August 23, 2016, 02:53:50 PM
@Dwachs
is there a way to get size of the map? ???
yes, from r7863 on: world.get_size()




Quote from: Yona-TYT 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
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.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on September 11, 2016, 04:13:40 PM
yes, from r7863 on: world.get_size()
Thank you !.


Quote from: Dwachs on September 11, 2016, 04:15:25 PM
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 .




Dwachs

Quote from: Yona-TYT 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
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.


Yona-TYT

#40
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



Yona-TYT

#41
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



Yona-TYT

@River, I will add connections rails and powerlines (it works now), what do you think this ?.






River

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.

Yona-TYT


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. ???

Yona-TYT


@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. ???


Dwachs

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.

Yona-TYT

#47

It is strange that this has never been seen. :o 
Thank you so much. :thumbsup: