Hello Modders!
Please could you help me with a (seemingly) minor issue?
I would love to be able to see on the map which settlements are Cities and which are not.
I spent ages renaming each city in my previous game to achieve that (I just renamed each city, putting "City" after each city's name). I'd like to automate this process.
Is it possible? Surely it must be, right?
If I have to work out how to do it myself, where should I begin? Script or GRF? Is there a modding tool, what do I need to know?
Suggestion : Label Cities on Generate
Moderator: OpenTTD Developers
Re: Suggestion : Label Cities on Generate
Hey, you can use GameScript to do it for you.
Here is an untested code that should do the trick:
You can use Minimmal GS by Zuu as the starting point, adding those lines in main.nut file.
Here is an untested code that should do the trick:
Code: Select all
// Get list of towns on map
// https://docs.openttd.org/gs-api/classGSTownList.html
local towns_list = GSTownList();
// GSList contains <item, value> pairs, where item is the id of the town
// and value is used for sorting, valuating, etc...
// https://docs.openttd.org/gs-api/classGSList.html
foreach (town_id, _ in towns_list) {
// Check if it is a city
if (GSTown.IsCity(town_id)) {
// Get name of the town
// https://docs.openttd.org/gs-api/classGSTown.html#afa4645c09372610446005f92c5b35945
local town_name = GSTown.GetName(town_id);
// Add (City) at the end
town_name += " (City)";
// Set new name of the town
// https://docs.openttd.org/gs-api/classGSTown.html#a3d4f59e3a19bec8a8b5c5e6253998b64
GSTown.SetName(town_id, town_name);
}
}
Who is online
Users browsing this forum: No registered users and 37 guests