News:

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

Factory_x should have "tile" list instead of "coord"

Started by Yona-TYT, November 28, 2022, 04:26:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

I made this little patch so that "get_tile_list" gets an array with "tile_x": CHG-Get-tile-list-in-factory_x.patch

faxtory_x(pos.x, pos.y).get_tile_list()



Yona-TYT

Test in action:
local fact = factory_x(pos.x, pos.y)
local list = fact.get_tile_list()
foreach(t in list) {
t.mark()
}

Captura desde 2022-11-28 05-06-54.png

Andarix

#4
Quote from: Yona-TYT on November 28, 2022, 09:02:05 AMI guess it's a bug in the doc, but what it actually returns is a "coord" array not a "tile_x" array. :o

This patch fixes just that. :P


And what's so bad about it if it's coord?

I'm afraid that this patch will demolish the script AI.

It would make more sense to make a function coord_to_tile_x for that.

Yona-TYT

Quote from: Andarix on November 28, 2022, 12:15:10 PMAnd what's so bad about it if it's coord?
I wanted to be consistent with the other "get_tile_list()" functions, since factory_x is the only class that doesn't return a "tile_x" array.


 Maybe making an additional function to make coord list independent is a good idea, something like get_coord_list().

Dwachs

If tile_x would actually be derived from coord3d then changing get_tile_list should not bring any problems.

But tile_x is not derived from coord3d, actually, which is another bug in the docs. Will see, what can be done.
Parsley, sage, rosemary, and maggikraut.

Dwachs

This is now in r10821. If there are any problems with existing scripts due to this change, please report back.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on November 30, 2022, 07:11:51 PMThis is now in r10821. If there are any problems with existing scripts due to this change, please report back.

You don't know how much I appreciate this!.  ;D

With this I am further optimizing the code of the basic class in the tutorial.

A lot of "coord" passed to "tile_x".  :P