News:

SimuTranslator
Make Simutrans speak your language.

[API Script] tile_x@ should not appear

Started by Yona-TYT, May 22, 2024, 12:52:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

A while ago the "tile_x" class began to inherit the "coord" so the behavior should be similar, however when passing tile_x to string "tostring() function" this happens.

It doesn't seem to be something difficult to fix.

Edt.
Apparently it's not what I thought, this is in "script_base.nut" and I can't think of anything to solve, I figured out that I only have to convert tile_x to coord3d


/**
 * class that contains data to get access to a tile (grund_t)
 */
class tile_x extends coord3d {

    _get = _extend_get
    function _tostring() { return "tile_x@" + coord3d_to_string(this) }

    function get_objects()
    {
        return tile_object_list_x(x,y,z)
    }
}

Edit.2

I can solve this by simply adding another specific function for coordinates.

/**
 * class that contains data to get access to a tile (grund_t)
 */
class tile_x extends coord3d {

    _get = _extend_get
    function _tostring() { return "tile_x@" + coord3d_to_string(this) }

    function coordstr() { return coord3d_to_string(this) }

    function get_objects()
    {
        return tile_object_list_x(x,y,z)
    }
}


Can we modify this?

ceeac

Quote from: Yona-TYT on May 22, 2024, 12:52:39 AMI can solve this by simply adding another specific function for coordinates.
I think you do not need a new function. Does coord3d_to_string(tile) not work?

Yona-TYT

Quote from: ceeac on May 22, 2024, 05:41:14 AMI think you do not need a new function. Does coord3d_to_string(tile) not work?
Yes, this work thanks 👍