0 Members and 1 Guest are viewing this topic.

#### Yona-TYT

« on: December 24, 2016, 10:51:10 AM »

Is it possible to know whether a section of road is connected ?, it would be helpful for the tutorial.

#### Yona-TYT

« Reply #1 on: December 30, 2016, 01:09:21 AM »
I suppose it is very difficult to achieve.

#### Leartin

« Reply #2 on: December 30, 2016, 10:55:34 AM »
There was a patch some time ago, which basically allowed to look for a route that almost exists...

http://forum.simutrans.com/index.php?topic=13376.0

I guess the original creator of the patch did not complete it, but it seemed to generally work (did not test myself), and only needed some cleanup. Maybe you can find someone to pick it up - if that was implemented in general, using it in scripting should be the easier part...

#### Yona-TYT

« Reply #3 on: December 30, 2016, 11:56:49 AM »
At the moment it is not possible (for me) to differentiate between a connected and another that is not. It would be a good idea to identify the ends of the ways, so you can get their type. The crosses are a good example of my idea.

#### An_dz

• Posts: 2594
• Total likes: 290
• D'oh
• Languages: PT, EN, (it, de)
« Reply #4 on: December 30, 2016, 01:29:12 PM »
Can't you get the ribi of a way? Dead end roads have ribis 1, 2, 4, and 8. I guess it's with way_x::get_dirs().

The Ribis are the directions the road is connected to. It's a 4 bit digit, each bit is one direction (NESW).

#### Yona-TYT

« Reply #5 on: December 30, 2016, 08:13:11 PM »
It works fine thanks

Code: [Select]
`local c_wayfor(local j=0;j<18;j++){c_way = coord3d(67,23+j,0)      if (c_way.y>29)         c_way.z=-1      if (tile_x(c_way.x, c_way.y, 0).find_object(mo_tunnel)){         coorbord = label1          continue      }            if (!tile_x(c_way.x, c_way.y, -1).find_object(mo_way))break      if ((way_x(c_way.x, c_way.y, c_way.z).get_dirs()==1) || (way_x(c_way.x, c_way.y, c_way.z).get_dirs()==2) || (way_x(c_way.x, c_way.y, c_way.z).get_dirs()==4)||(way_x(c_way.x, c_way.y, c_way.z).get_dirs()==8)){      coorbord = c_way      if (c_way.y!=23 && c_way.y!=40)break      }if(j==17){   this.next_step()   reset_pot()               }`
« Last Edit: December 30, 2016, 08:31:08 PM by Yona-TYT »

#### An_dz

• Posts: 2594
• Total likes: 290
• D'oh
• Languages: PT, EN, (it, de)
« Reply #6 on: December 30, 2016, 08:50:55 PM »
Why don't you save way_x(c_way.x, c_way.y, c_way.z).get_dirs() in a variable?

Code: [Select]
`local ribi = way_x(c_way.x, c_way.y, c_way.z).get_dirs()if (ribi == 1 || ribi == 2 || ribi == 4 || ribi == 8) {`

#### Yona-TYT

`local ribi = way_x(c_way.x, c_way.y, c_way.z).get_dirs()if (ribi == 1 || ribi == 2 || ribi == 4 || ribi == {`