From 155b2237049cc15246f825e86d21aa7690e79277 Mon Sep 17 00:00:00 2001
From: Yona-TYT <yonatan.el.amigo@gmail.com>
Date: Wed, 1 Jan 2025 21:18:12 -0400
Subject: [PATCH] ADD support for iterate tile_x

---
 src/simutrans/script/api/api_tiles.cc | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/simutrans/script/api/api_tiles.cc b/src/simutrans/script/api/api_tiles.cc
index 3b26b1e94..b8419e8ab 100644
--- a/src/simutrans/script/api/api_tiles.cc
+++ b/src/simutrans/script/api/api_tiles.cc
@@ -150,6 +150,19 @@ void export_tiles(HSQUIRRELVM vm)
 	 */
 	begin_class(vm, "tile_x", "coord3d,extend_get,ingame_object");
 
+	/**
+	 * Meta-method to be used in foreach loops to loop over all objects on the tile. Do not call it directly.
+	 */
+	register_function(vm, get_next_object,  "_nexti",  2, "x o|i");
+	/**
+	 * Meta-method to be used in foreach loops to loop over all objects on the tile. Do not call it directly.
+	 */
+	register_function(vm, get_object_index, "_get",    2, "x i|s");
+	/**
+	 * Returns number of objects on the tile.
+	 * @typemask integer()
+	 */
+	register_function(vm, get_object_count, "get_count",  1, "x");
 	/**
 	 * Constructor. Returns tile at particular 3d coordinate.
 	 * If not tile is found, it returns the ground tile.
-- 
2.47.1

