Author Topic: Get coordinates "z"  (Read 613 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

Get coordinates "z"
« on: March 09, 2017, 10:02:27 PM »

I do not know if it is possible, but I would like to get the height of a tile (even if it is empty).

Offline jameskuyper

Re: Get coordinates "z"
« Reply #1 on: March 10, 2017, 06:17:55 PM »
I've carefully studied the documentation, but I have not had time to do any testing, and I have no actual experience with scripting for simutrans. However, since no one better qualified than me has answered yet, I'll give it a shot.

tile_x is derived from coord3d, and is therefore supposed to have a member named z that gives the height. If you don't already have a tile_x object, and what you want is to know the ground-level height for a given value of x and y, I think you can construct a square_x object using x and y, and then call get_ground_tile() to obtain a tile_x object describing the ground-level tile in that square.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4189
  • Total likes: 154
  • Helpful: 148
  • Languages: EN, DE, AT
Re: Get coordinates "z"
« Reply #2 on: March 10, 2017, 06:19:43 PM »
Yes, this should work.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Get coordinates "z"
« Reply #3 on: March 10, 2017, 09:56:06 PM »
Thanks, this saves me a few lines of code.  ;)

Offline jameskuyper

Re: Get coordinates "z"
« Reply #4 on: March 11, 2017, 08:23:00 PM »
Note: while checking this out, I noticed that <http://dwachs.github.io/simutrans-sqapi-doc/classtile__x.html> describes the second and third parameters of the tile_x constructor as both being named 'y', and in the description below, it describes both 'y' parameters as having the same meaning: "z-coordinate".  Someone needed some sleep when they wrote that.  :-)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4189
  • Total likes: 154
  • Helpful: 148
  • Languages: EN, DE, AT
Re: Get coordinates "z"
« Reply #5 on: March 11, 2017, 09:47:15 PM »
I also noticed this :) Should be correct now.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Get coordinates "z"
« Reply #6 on: March 25, 2017, 10:06:44 PM »
Is it possible to get the height of the underground slope?  ???



Offline jameskuyper

Re: Get coordinates "z"
« Reply #7 on: March 25, 2017, 11:43:01 PM »
If, by any means, you can obtain a tile_x object describing the slope of interest, the z member contains the height, and get_slope() returns the encoded slope of the tile. I've seen a description of the encoding scheme, but I can't find it right now. My (unreliable memory) is that the z component gives the height of the lowest corner of the tile, and the encoded slope has two (or four?) bits per corner, in a specific order, giving the height of that corner above the lowest corner.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4189
  • Total likes: 154
  • Helpful: 148
  • Languages: EN, DE, AT
Re: Get coordinates "z"
« Reply #8 on: March 27, 2017, 06:53:31 AM »
@Yona what exactly would you like to get? the total height of the slope, ie one of 0,1,2 ?
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: Get coordinates "z"
« Reply #9 on: March 27, 2017, 03:14:31 PM »
@Yona what exactly would you like to get? the total height of the slope, ie one of 0,1,2 ?
I need to get the coordinates of the marked road.
Is it possible to get the height of the underground slope?  ???