The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on November 28, 2022, 04:26:57 AM

Title: Factory_x should have "tile" list instead of "coord"
Post by: Yona-TYT on November 28, 2022, 04:26:57 AM
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()
Title: Re: Factory_x should have "tile" list instead of "coord"
Post by: Andarix on November 28, 2022, 08:53:56 AM
??

http://dwachs.github.io/simutrans-sqapi-doc/classfactory__x.html#a59a5d79eac6ae4618c34f382c616b4d3 (http://dwachs.github.io/simutrans-sqapi-doc/classfactory__x.html#a59a5d79eac6ae4618c34f382c616b4d3)
Title: Re: Factory_x should have "tile" list instead of "coord"
Post by: Yona-TYT on November 28, 2022, 09:02:05 AM
Quote from: Andarix on November 28, 2022, 08:53:56 AM??
http://dwachs.github.io/simutrans-sqapi-doc/classfactory__x.html#a59a5d79eac6ae4618c34f382c616b4d3 (http://dwachs.github.io/simutrans-sqapi-doc/classfactory__x.html#a59a5d79eac6ae4618c34f382c616b4d3)
I 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
Title: Re: Factory_x should have "tile" list instead of "coord"
Post by: Yona-TYT on November 28, 2022, 09:09:20 AM
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
Title: Re: Factory_x should have "tile" list instead of "coord"
Post by: Andarix on November 28, 2022, 12:15:10 PM
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.
Title: Re: Factory_x should have "tile" list instead of "coord"
Post by: Yona-TYT on November 28, 2022, 12:44:11 PM
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().
Title: Re: Factory_x should have "tile" list instead of "coord"
Post by: Dwachs on November 28, 2022, 03:24:19 PM
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.
Title: Re: Factory_x should have "tile" list instead of "coord"
Post by: Dwachs on November 30, 2022, 07:11:51 PM
This is now in r10821. If there are any problems with existing scripts due to this change, please report back.
Title: Re: Factory_x should have "tile" list instead of "coord"
Post by: Yona-TYT on December 09, 2022, 01:50:53 AM
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