The International Simutrans Forum

 

Author Topic: [online] Scenario to share regions in multiplayer.  (Read 5609 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

  • Devotee
  • *
  • Posts: 1451
    • Simutrans-BLOG
  • Languages: ES
[online] Scenario to share regions in multiplayer.
« on: February 23, 2018, 10:59:00 PM »
[Script updated 12-25-2019]
Hello everyone, I have finished this beautiful script for the multiplayer mode (one of the few that exist).

I would like someone to try this on a server, since I do not have a PC of my own I'm afraid  :-[ .


Scenario --> Region-v0.1.zip

This is an amendment to my previous code, so many of the functions are the same. (https://forum.simutrans.com/index.php?topic=15388.msg152149#msg152149)

Configure regions:
Only the server "Using the public service" can manage the regions, this is achieved from the "Rules" tab in the scenario window.:
1- choose the number of regions on the map, the values ​​are "2,4,6,8 and 12".
2- select the climate of the borders: 2 types of climate are used, one to create the divisions and the other to hide them.

Number of players:
all players, with exemption of 13 and "Human" can have their own region, as long as there is an available region.

Share region:
Using the "gate road", you can choose any player to share your region. If you stop sharing the region with a player, he can still remove objects, but only if they are his property.

Stations / stops:
Players can eliminate any station from any player, but only if it is within the limits of their region.

Public stations:
Players can eliminate any public service station but only if it is within the limits of their region.


« Last Edit: December 25, 2019, 10:59:12 PM by Yona-TYT »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4702
  • Languages: EN, DE, AT
Re: [online] Scenario to share regions in multiplayer.
« Reply #1 on: February 24, 2018, 03:01:32 PM »
Nice idea!

You can set in the scenario script
Code: [Select]
map.file = "<attach>"
Then when loading the scenario, it is applied to the current running game. No need to copy sve files around ;)

Offline Yona-TYT

  • Devotee
  • *
  • Posts: 1451
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Scenario to share regions in multiplayer.
« Reply #2 on: February 25, 2018, 10:36:59 PM »
Nice idea!

You can set in the scenario script
Code: [Select]
map.file = "<attach>"
Then when loading the scenario, it is applied to the current running game. No need to copy sve files around ;)
This is great, but is it possible to do this ?? ... it would be nice.

Ready, I changed this  ;D .

Offline Yona-TYT

  • Devotee
  • *
  • Posts: 1451
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Scenario to share regions in multiplayer.
« Reply #3 on: February 27, 2018, 09:49:16 PM »
New version ready for testing  :D

Scenario:  region-lite-v2.2.zip

Changes:
A savegame file is no longer necessary, now the script uses the current game "map.file =" <attach> "".
A few adaptations to make it work in any pakser, as long as it has gate road.


Offline Yona-TYT

  • Devotee
  • *
  • Posts: 1451
    • Simutrans-BLOG
  • Languages: ES
Re: [online] Scenario to share regions in multiplayer.
« Reply #4 on: December 25, 2019, 10:19:52 PM »
Script to divide the map into regions.
Script: https://www.mediafire.com/file/536fwtbfr8txflu/regions-v0.1.zip/file

Because the previous files were lost, I have written this script almost from scratch.

The big difference now is that all settings are made using "text script" from the Scenarion window.
I updated the first post of the topic!.



Now the code is much more organized, which means that it is much easier to adapt another script without modifying much.


This is an example combining the "Regions" and the points system created by our friend @Dwachs.
Script --> regions-and-points.zip

This is the template:
Code: [Select]
/// load current game
map.file = "<attach>"

/// short description to be shown in finance window
/// and in standard implementation of get_about_text
scenario.short_description = "Regions"
scenario.author = "Yona-TYT"
scenario.version = "1.0"
scenario.translation  <- "Yona-TYT"

const save_version = 1

include("regions")

persistent <- {
    //Para Guardar los datos del script -----------------------
    region_data_all = region_data_all
    //-------------------------------------
}

function get_info_text(pl)
{
    local info = ttextfile("info.txt")
    local text = ""

    info.reg = region_get_info_text(pl) //Regions
    return info.tostring()
}
function get_rule_text(pl)
{
    local num = all_pl[0]
   
    local rule = ttextfile("rule.txt")
    if (pl==1) {rule = ttextfile("rule_pub.txt")}

    rule.reg = region_get_rule_text(pl).rg //Regions Selec
    rule.clm = region_get_rule_text(pl).cl //Regions Climate
    rule.wga = region_get_rule_text(pl).wg //Regions Climate
    return rule.tostring()
}

function get_result_text(pl)
{
    local result = ttextfile("result.txt")

    return result.tostring()
}
function get_goal_text(pl)
{
    local goal = ttextfile("goal.txt")   
    goal.reg = region_get_goal_text(pl) //Regions
    return goal.tostring()
}

function is_scenario_completed(pl)
{
    //Para las regiones -------------------------------
    region_is_scenario_completed(pl)
    //--------------------------------------------------
    return 1
}

function is_work_allowed_here(pl, tool_id, pos)
{
    local result = region_is_work_allowed_here(pl, tool_id, pos) //Para las regiones

    return result
}

function start()
{
    region_start() //Para las regiones
}

function is_tool_allowed(pl, tool_id, wt)
{
    return true
}

function resume_game()
{
    region_resume_game() //regions Funtion
}
« Last Edit: December 25, 2019, 10:35:50 PM by Yona-TYT »