The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on May 29, 2018, 05:16:25 PM

Title: tile_x.is_empty() says false with water.
Post by: Yona-TYT on May 29, 2018, 05:16:25 PM
I have a problem with the logic of climate, water is an object? or is it a climate?

the tile_x.is_empty() function returns false when the climate is water, is this an error?
Title: Re: tile_x.is_empty() says false with water.
Post by: Yona-TYT on May 29, 2018, 05:25:42 PM
I need a function that indicates if the tile is empty, and that it works in the water and on land.
Title: Re: tile_x.is_empty() says false with water.
Post by: Dwachs on May 29, 2018, 06:21:35 PM
you can use the following check

return tile.is_water()  &&  (tile.find_object(mo_building)==null)  &&  (tile.find_object(mo_depot_water)==null)

on water tiles, and is_empty() for all other tiles.
Title: Re: tile_x.is_empty() says false with water.
Post by: Yona-TYT on May 29, 2018, 06:35:52 PM
Quote from: Dwachs on May 29, 2018, 06:21:35 PMyou can use the following check return tile.is_water()  &&  (tile.find_object(mo_building)==null)  &&  (tile.find_object(mo_depot_water)==null) on water tiles, and is_empty() for all other tiles.
Thanks, although I confess that I would like it to be practical, using only one function.  ;)
Edit.
This works well:tile.get_objects().get_count() != 0