The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on March 09, 2017, 10:02:27 PM

Title: Get coordinates "z"
Post by: Yona-TYT 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).
Title: Re: Get coordinates "z"
Post by: jameskuyper 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.
Title: Re: Get coordinates "z"
Post by: Dwachs on March 10, 2017, 06:19:43 PM
Yes, this should work.
Title: Re: Get coordinates "z"
Post by: Yona-TYT on March 10, 2017, 09:56:06 PM
Thanks, this saves me a few lines of code.  ;)
Title: Re: Get coordinates "z"
Post by: jameskuyper 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 (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.  :-)
Title: Re: Get coordinates "z"
Post by: Dwachs on March 11, 2017, 09:47:15 PM
I also noticed this :) Should be correct now.
Title: Re: Get coordinates "z"
Post by: Yona-TYT on March 25, 2017, 10:06:44 PM
Is it possible to get the height of the underground slope?  ???

(https://www.mediafire.com/convkey/2ecb/z8oiudu49ic7uoq6g.jpg)
Title: Re: Get coordinates "z"
Post by: jameskuyper 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.
Title: Re: Get coordinates "z"
Post by: 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 ?
Title: Re: Get coordinates "z"
Post by: Yona-TYT on March 27, 2017, 03:14:31 PM
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?  ???

(https://www.mediafire.com/convkey/2ecb/z8oiudu49ic7uoq6g.jpg)