The International Simutrans Forum

 

Author Topic: tile_x.is_empty() says false with water.  (Read 259 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1174
    • Simutrans-BLOG
  • Languages: ES
tile_x.is_empty() says false with water.
« 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?

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1174
    • Simutrans-BLOG
  • Languages: ES
Re: tile_x.is_empty() says false with water.
« Reply #1 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4555
  • Languages: EN, DE, AT
Re: tile_x.is_empty() says false with water.
« Reply #2 on: May 29, 2018, 06:21:35 PM »
you can use the following check
Code: [Select]
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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1174
    • Simutrans-BLOG
  • Languages: ES
Re: tile_x.is_empty() says false with water.
« Reply #3 on: May 29, 2018, 06:35:52 PM »
you can use the following check
Code: [Select]
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:
Code: [Select]
tile.get_objects().get_count() != 0