Author Topic: Create rectangles on the minimap using script.  (Read 1069 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

Create rectangles on the minimap using script.
« on: June 07, 2016, 04:06:09 AM »

This is necessary to map divided into regions... http://forum.simutrans.com/index.php?topic=15388.msg151671#msg151671


But it can also be useful if you need to delimit regions of the map in any scenario.
Playing around with the code i made this:



I did not find how to rotate the map, always mantien a fixed position.
Also not i found as turn this into a function  of script scenario.
Code: [Select]

      koord tt[4];
      int x1,x2, y1=512, y2, sizx = 168, sizy = 125;
      for(int vv=0;vv<4;vv++) {
         if(vv!=0)y1-=sizy+3;
         x1=0;
         x2=0;
         y2=0;
         for(int cc=0;cc<3;cc++) {
            if(x1!=0)x1=x2+1;
            else x1+=1;
         
            x2 = x1+sizx+1;
            if(vv==0)y2 = y1-sizy-3;
            else y2 = y1-sizy-3;
            koord tt0(x1-1,y1);
            koord tt2(x2,y2);
            tt[1]=koord(tt0.x, tt2.y);
            tt[3]=koord(tt2.x, tt0.y);
            tt[0]=koord(tt0.x, tt0.y);
            tt[2]=koord(tt2.x, tt2.y);
            scr_coord yona[4];


            for(uint i=0; i<lengthof(yona); i++) {
               yona[i]= karte_to_screen(tt[i])+pos;
            }
               
            display_direct_line_dotted( yona[0].x,yona[0].y, yona[1].x, yona[1].y, 5, 5, COL_YELLOW );
            display_direct_line_dotted( yona[1].x,yona[1].y, yona[2].x, yona[2].y, 5, 5, COL_YELLOW );
            display_direct_line_dotted( yona[2].x,yona[2].y, yona[3].x, yona[3].y, 5, 5, COL_YELLOW );
            display_direct_line_dotted( yona[3].x,yona[3].y, yona[0].x, yona[0].y, 5, 5, COL_YELLOW );
            }


         }

Offline Tjoeker

Re: Create rectangles on the minimap using script.
« Reply #1 on: June 07, 2016, 02:23:55 PM »
I'd love to be able to divide the map into regions/countries. However, I'd like to draw lines instead of rectangles... (or making multiple rectangles 1 region).
In a normal Simutrans game, this could be optional and is purely visual. and if you could script things for regions in scenarios this would be a huge +1! (as I'm planning a scenario with countries as well :) )

I know borders has been requested before, but I hope this gets reconsideration as this doesn't change gameplay in 'sandbox' mode, but opens up many possibilities for scenarios.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8561
  • Total likes: 253
  • Helpful: 226
  • Languages: De,EN,JP
Re: Create rectangles on the minimap using script.
« Reply #2 on: June 07, 2016, 09:18:15 PM »
Drawing lines between coordinates is be easy, the same is done to show for instance industry connections. I think the interface to scenarios would be more difficult.

Offline Yona-TYT

Re: Create rectangles on the minimap using script.
« Reply #3 on: June 08, 2016, 01:54:26 AM »
In that case, you could implement a function to mark rectangles directly on the minimap and then send to a "savegame". This might work  ;D .


Then you can use a script so that only the public service can use it.  ;)
« Last Edit: June 08, 2016, 02:05:30 AM by Yona-TYT »

Offline Yona-TYT

Re: Create rectangles on the minimap using script.
« Reply #4 on: June 08, 2016, 02:46:27 AM »
I'd love to be able to divide the map into regions/countries. However, I'd like to draw lines instead of rectangles... (or making multiple rectangles 1 region).
In a normal Simutrans game, this could be optional and is purely visual. and if you could script things for regions in scenarios this would be a huge +1! (as I'm planning a scenario with countries as well ☺ )

I know borders has been requested before, but I hope this gets reconsideration as this doesn't change gameplay in 'sandbox' mode, but opens up many possibilities for scenarios.



I'm glad your interest in these scenarios  ☺ .
Here the work of map divided into regions and scores of dwachs.
regions.zip

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4068
  • Total likes: 98
  • Helpful: 146
  • Languages: EN, DE, AT
Re: Create rectangles on the minimap using script.
« Reply #5 on: June 08, 2016, 06:27:39 AM »
In that case, you could implement a function to mark rectangles directly on the minimap and then send to a "savegame". This might work  ;D .
I am thinking about a possible implementation. The main problem is to broadcast such information to all clients.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Create rectangles on the minimap using script.
« Reply #6 on: June 08, 2016, 07:57:26 PM »
You can also use a placeholder to enter the coordinates and a name for the rectangle, this seems easier I think.


Edit.
It would also be good to enter the coordinates with a selection tool, which would be more practical I think.
« Last Edit: June 10, 2016, 09:29:23 AM by Yona-TYT »