News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Get coordinates "z"

Started by Yona-TYT, March 09, 2017, 10:02:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT


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

jameskuyper

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.

Dwachs

Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Thanks, this saves me a few lines of code.  ;)

jameskuyper

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

Dwachs

I also noticed this :) Should be correct now.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Is it possible to get the height of the underground slope?  ???



jameskuyper

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.

Dwachs

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

Yona-TYT

Quote from: Dwachs 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 ?
I need to get the coordinates of the marked road.
Quote from: Yona-TYT on March 25, 2017, 10:06:44 PM
Is it possible to get the height of the underground slope?  ???