The International Simutrans Forum

 

Author Topic: Error using "find_object(mo_building)"  (Read 935 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

  • Devotee
  • *
  • Posts: 1845
    • Simutrans-BLOG
  • Languages: ES
Error using "find_object(mo_building)"
« on: May 24, 2020, 05:54:26 PM »

In some cases the buildings / constructions are not not achieved, I suppose it may be due to the abrupt terrain.

Here is the savegame and a test script ->  https://www.mediafire.com/file/sl7nxgp3wsc2awv/test-yona.zip/file

Code: [Select]
    local c_city = coord(70,409)
    local build = square_x(c_city.x,c_city.y).get_ground_tile().find_object(mo_building)
   

    if (build) gui.add_message("Is correct : "+build+"")

    else gui.add_message("Is null : "+build+"")

Offline Andarix

  • *
  • Posts: 370
  • Languages: de
Re: Error using "find_object(mo_building)"
« Reply #1 on: May 24, 2020, 06:16:59 PM »
Code: [Select]
local tile = square_x(70,409)
local c_city = tile_x(tile_x, tile.y, tile.get_ground_tile())
local build = c_city.find_object(mo_building)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4957
  • Languages: EN, DE, AT
Re: Error using "find_object(mo_building)"
« Reply #2 on: May 24, 2020, 06:25:30 PM »
What exactly is the bug?

Offline Yona-TYT

  • Devotee
  • *
  • Posts: 1845
    • Simutrans-BLOG
  • Languages: ES
Re: Error using "find_object(mo_building)"
« Reply #3 on: May 24, 2020, 08:20:40 PM »
Upgrade:

I made a comparison with a monument, using the same methods:
Code: [Select]
    // City Wakefield Pos ---------------------------------------------------------------
    local c1_city = coord(70,409)
    local build1 = square_x(c1_city.x,c1_city.y).get_ground_tile().find_object(mo_building)

    if (build1) {gui.add_message("City Wakefield Is correct : "+build1+"")}
    else {gui.add_message("City Wakefield Is null : "+build1+"")}

    // Monument Pos----------------------------------------------------------------------
    local c2_city = coord(95,33) 
    local build2 = square_x(c2_city.x,c2_city.y).get_ground_tile().find_object(mo_building)

    if (build2) {gui.add_message("Monument Pos Is correct : "+build2+"")}
    else {gui.add_message("Monument Pos Is null : "+build2+"")}

The displayed result is as follows:
Code: [Select]
Monument Pos Is correct : (instance : 0x0x555962a4f750)
City Wakefield Is null : (null : 0x(nil))

I suspect it is a problem that only affects multi-tile buildings.
  Correct, it only seems to affect the town hall




Code: [Select]
local tile = square_x(70,409) local c_city = tile_x(tile_x, tile.y, tile.get_ground_tile()) local build = c_city.find_object(mo_building)
This is basically the same, I have tried and it is indeed the same result



Just out of curiosity, why do the instances change between two values? In this example "0x0x555961e625c0" and "0x0x555961e625c0"
Shouldn't I keep only one?.
Code: [Select]
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
Monument Pos Is correct : (instance : 0x0x555961e625c0)
Monument Pos Is correct : (instance : 0x0x5559629bd5b0)
« Last Edit: May 24, 2020, 09:13:28 PM by Yona-TYT »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4957
  • Languages: EN, DE, AT
Re: Error using "find_object(mo_building)"
« Reply #4 on: May 25, 2020, 06:07:53 AM »
I do not know, what you are doing. But at (70,409) there is no townhall in the savegame. The townhal is at (72,409) -(73,410).

Please upload a minimal example showing the wrong behaviour. I do not want to edit a randomly given script to produce an error message.

Offline Yona-TYT

  • Devotee
  • *
  • Posts: 1845
    • Simutrans-BLOG
  • Languages: ES
Re: Error using "find_object(mo_building)"
« Reply #5 on: May 25, 2020, 12:45:19 PM »
But  (70,409) is that the location that the window shows me?..... Shouldn't the title bar show the position (72,409)?.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4957
  • Languages: EN, DE, AT
Re: Error using "find_object(mo_building)"
« Reply #6 on: May 25, 2020, 01:30:11 PM »
It shows the centre of the rectangle formed by the city borders.