diff --git a/Using-Track-Block-Get-Previous.md b/Using-Track-Block-Get-Previous.md new file mode 100644 index 0000000..d2f1526 --- /dev/null +++ b/Using-Track-Block-Get-Previous.md @@ -0,0 +1,24 @@ +Pasted from gitter. + +Track blocks are what you place when you use the ride construction window i.e. they can be made up of multiple map elements. I know for your function its only one element but we should use track block get previous as it adds some protection. You have to pass the `x` and `y` coordinates of the start of the track block and the `map_element` of the tile. I suggest doing it like thus: + +```C +rct_map_element* trackElement = +map_get_track_element_at_of_type_seq( + x, + y, + z / 8, + trackType, + 0); + +rct_xy_element input; + +input.x = x; +input.y = y; +input.element = trackElement; +track_begin_end output; +``` + +The `output` is a `track_begin_end` structure. The `track_begin_end` structure should in theory give `x`, `y` coordinates of the start and end of a track block and the `map_element`'s associated with either end. In general you should only concern yourself with the begin variables. + +Now using `track_block_get_previous` is pretty simple. It returns `false` if it fails to find the next track block and `true` if it does find another block. On failure do not trust the contents of the `output`. \ No newline at end of file