Setting station names from nearby industries

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
3iff
Tycoon
Tycoon
Posts: 1094
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Setting station names from nearby industries

Post by 3iff »

I'm playing around with coding of Firs, but as this is more of a general NML question, I'm asking here. I want to expand the range of automatic names when placing a station near to an industry.

Below is the code from Firs. It currently generates a string name of "Town" + "Manor"

nearby_station_name: string(STR_STATION, string(STR_TOWN), string(STR_STATION_FARM));

I want to have the possibility of selecting string(STR_STATION_FARM) or string(STR_STATION_FARM1) and so on possibly up to FARM6 (or some range of strings I've added to the lang file) but I can't quite work out how to do this so that any of the 6-7 possibilities can be randomly selected. I'm suspecting that I need to use SWITCH to return one of the FARMx strings but I don't know how to tie it all together.

Any suggestions?

Thanks in advance.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Setting station names from nearby industries

Post by planetmaker »

3iff wrote: nearby_station_name: string(STR_STATION, string(STR_TOWN), string(STR_STATION_FARM));
nearby_station_name is only available as property. Thus you can give it one value but not more.

In order to apply a switch nearby_station_name would need be become available (also) as callback - which currently it is not; that will need an extension of the grf specs / additional code in OpenTTD. Beware there might be dragons lurking in the station names;): the callback, once called for a station, must at all times and under all circumstances return the same value henceforth - a thing which would need to be enforced on the OpenTTD side instead of NewGRF side or we get yet another desync issue; which might be circumvented if the station name is stored as custom station name as a station property.

EDIT: alternatively the propertycould become a list of strings (in grf v9, or another property in grf <v9) and the industry assigned upon creation a random number which gives the actual string to be used.
User avatar
3iff
Tycoon
Tycoon
Posts: 1094
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Setting station names from nearby industries

Post by 3iff »

I think I understand, so I'm limited to one fixed (custom) name per industry. That's slightly disappointing but I can live with that.

Thanks.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 23 guests