Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Add variable for xy coordinates of industries #218

Open
2TallTyler opened this issue May 27, 2021 · 5 comments
Open

Request: Add variable for xy coordinates of industries #218

2TallTyler opened this issue May 27, 2021 · 5 comments

Comments

@2TallTyler
Copy link
Member

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.

@frosch123
Copy link
Member

frosch123 commented May 27, 2021

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

@2TallTyler
Copy link
Member Author

Thank you for pointing me in the right direction. The test code you gave me works great!

@andythenorth
Copy link
Contributor

andythenorth commented Oct 10, 2021

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.

@andythenorth
Copy link
Contributor

This issue could be closed IMHO :)

@2TallTyler
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants