News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Error using "find_object(mo_building)"

Started by Yona-TYT, May 24, 2020, 05:54:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT


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

    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+"")

Andarix


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)

Dwachs

Parsley, sage, rosemary, and maggikraut.

Yona-TYT

#3
Upgrade:

I made a comparison with a monument, using the same methods:
    // 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:
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





Quote from: Andarix on May 24, 2020, 06:16:59 PM 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?.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)

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

But  (70,409) is that the location that the window shows me?..... Shouldn't the title bar show the position (72,409)?.

Dwachs

It shows the centre of the rectangle formed by the city borders.
Parsley, sage, rosemary, and maggikraut.