Page 1 of 1

How to influence city growth?

Posted: 14 Aug 2019 20:25
by Erato
Hey!

I'm currently working on a building set and I was wondering how I could make it so certain types of towns or cities need different types of cargo to grow, and if it is possible to influence the speed of this growth, but I cannot find anything in the NML documentation.

For instance, how could I make it such that a city would require goods to grow if the population is bigger than 10.000?

Thanks in advance!

Re: How to influence city growth?

Posted: 15 Aug 2019 05:45
by jfs
Restrictions like "require goods to grow if the population is bigger than 10.000" can only be implemented via a game script.

Re: How to influence city growth?

Posted: 15 Aug 2019 05:51
by Andrew350
EDIT: jfs posted while I was writing, and what he said is generally true, but as long as ALL houses are defined as I wrote below it can still work :)

As far as I know there's no way to change the speed of town growth, at least when it comes to the number of new houses OpenTTD builds over time, as that is hardcoded. You can, however, alter it slightly by imposing "rules" for your houses by restricting the conditions in which they will be built by using the construction_check callback. This particular callback can be abused a lot to influence how, when, and what type of buildings will appear depending on the variables you feed it.

Using your example, you could define a house using the construction_check callback to disallow construction above 10,000 population unless goods are delivered nearby, maybe something like this:

Code: Select all

switch (FEAT_HOUSES, SELF, switch_goods_check, cargo_accepted_nearby_last_month(GOOD, 0, 0)) {
	1: 1;
	0;
}
switch (FEAT_HOUSES, PARENT, switch_pop_check, population) {
	0..9999: 1;
	switch_goods_check;
}
...
...
graphics {
		construction_check:  switch_pop_check;
	}
Notice the PARENT scope of that first switch which opens up some new town variables such as population ;) Of course this is a basic example and there is tons of stuff you can do, for example by utilizing the protection callback to stop certain buildings from being destroyed or checking for similar buildings nearby using the same_class_count_town and similar variables to create a sort of "neighborhood" effect.

You can make it as simple or complicated as you wish but OpenTTD growth mechanics will always apply, so you may need to get...creative to work around it a little bit if that's not desired ;) I've only done a little bit of town growth stuff in Wasteland, but if you have any specific questions I'll gladly try to help where I can :)

Re: How to influence city growth?

Posted: 20 Aug 2019 16:21
by Erato
Thanks for the help. I think I'll go with making a Gamescript. It seems more appropriate for what I want to achieve. Thanks anyway.