nml
nml copied to clipboard
Request: Add variable for xy coordinates of industries
Industries and industrytiles currently have no way of knowing their location on the map, unlike houses which have x_coordinate
and y_coordinate
variables. I would like to request similar variables for industries.
My desired use case is generating Import/Export industries only near the edge of the map. Another case would be separating the map into quadrant "regions" with different primary resources (coal, iron, etc) available in each.
On Discord, @andythenorth informs me that "80+ var 00" contains the xy coordinates of the industry's northernmost tile, per this page.
I am not knowledgeable enough to know how to use this, and the depreciated syntax page of the docs suggested opening a feature request to formally implement this in NML.
General warning: The linked page is TTDPatch specific, and not everything on it applies to OpenTTD. In this case the description of var 80+x assumes a 256x256 map :p
On top of that: the location_check
callback is special, nothing from that page applies to it. Though by coincidence 0x80 has the same meaning here.
For testing you can use this:
X coordinate = var[0x80, 0, 0xFFFFFFFF] % map_x_edge
Y coordinate = var[0x80, 0, 0xFFFFFFFF] / map_x_edge
Thank you for pointing me in the right direction. The test code you gave me works great!
I have a case where it would be helpful to have a UUID for industry instances. I am not aware of an actual UUID that is grf-readable (maybe in 80+?).
xy is unique, so if there was a way to parse the returned value for uniqueness, it would work for my case. Maybe evaluating x and y separately would work fine.
This issue could be closed IMHO :)
I disagree. It would be nice to have an easy variable to read (and put in the docs) rather than forcing the user to perform the above calculation, even if it does work.