[GS] Villages Is Villages

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Timberwolf
Engineer
Engineer
Posts: 86
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

[GS] Villages Is Villages

Post by Timberwolf »

Fed up with a single bus service turning every town into a metropolis? Tired of your maps being full of industries after a century of gameplay? Me too. That's why I created Villages Is Villages - a game script to stop those pesky towns from growing too big for their boots.

Town growth rules are changed as follows:
  • Cities are limited in growth solely by the provision of transport service (although limits may be imposed by newGRF sets).
  • All other towns have a maximum population to which they may grow. The town information window will show the growth potential of a town so you can decide what kind of transport service to provide.
  • Towns can be grown beyond their initial limit by transporting goods, building materials, food and alcohol (some cargoes may require FIRS or a similar industry NewGRF) or by directly funding expansion using the "Fund New Buildings" option.
In addition, you can configure the minimum amounts of mail and passengers to be transported from the town before it can grow so towns and cities will only grow if they have a sufficiently comprehensive passenger/mail network.

There is also an experimental feature to manage industries, which will prevent new industries from opening unless a (configurable) proportion of those already on the map have service. As this currently relies on manipulating a game setting this is marked as experimental, although it has worked in all my testing so far.

The script behaves fairly well on large and densely-populated maps; it handles 20,000 industries on the map with no problem, but more than about 2000 towns mean it can take over a month of game time for all of the towns to be updated on first load. (The script employs some caching and smarter decisions on when to update towns on subsequent runs).

This is the first time I've written a game script - or anything in Squirrel for that matter - so no promises that the code is good, idiomatic Squirrel or that there won't be unexpected bugs. I haven't encountered any problems in testing (even for situations which crash several AIs) but of course that just means I haven't encountered them, not that they don't exist :)

Comments, suggestions and bug reports welcome.

The script is on BaNaNaS, or you can download version 1 from the attachment. Tested with OpenTTD 1.6.0.

You will need SuperLib for NoGo version 39 (note there are two versions of SuperLib, one for AIs and one for game scripts) installed - this is listed as a dependency in BaNaNaS, but outside of that you'll need to install it manually.
Attachments
Villages_Is_Villages-9.tar
(60 KiB) Downloaded 96 times
Last edited by Timberwolf on 14 Jun 2016 18:56, edited 6 times in total.


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

Re: [GS] Villages Is Villages

Post by 3iff »

I'm getting this. No idea why. I've downloaded SuperLib-39.tar and it's curently in 3 different folders, just in case it might not be in the 'right' one...

I do generally know what I'm doing...(downloaded ViV.tar from this thread).
Unnamed, 1st Jan 1930.png
Unnamed, 1st Jan 1930.png (89.68 KiB) Viewed 6557 times

Ah, it wants Superlib for NoGo, so I got that and now I get the following. I'm using SPI v1.2 (as yet unreleased) but it shouldn't be causing problems. I'll try a clear newgrf environment in a few minutes.
(I've extracted the files into a folder called ViV so I can see what it's trying to do.)
Unnamed, 1st Jan 1930#1.png
Unnamed, 1st Jan 1930#1.png (35.22 KiB) Viewed 6556 times
Yeah, blows up even with a newgrf-free game.

Timberwolf
Engineer
Engineer
Posts: 86
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: [GS] Villages Is Villages

Post by Timberwolf »

That's interesting - looks like it's running into some problems with the language file. It's also not finding the compatibility script for API version 1.5 (AFAIK there haven't been any material changes 1.5 -> 1.6), I don't know if that would have an impact. I'll give that a try my end.

Which version of OpenTTD are you running?
Any chance I could get a screenshot of the folder you extracted the .tar file to?

The SuperLib for NoGo is a problem I ran into as well - there's a different version between AI and NoGo, I was convinced I'd downloaded version 39 until I realised I was looking at the AI version It's fine if you download from BaNaNaS, but of course I forgot about using the .tar directly. I'll make a note on the first post so nobody else gets caught out.
Last edited by Timberwolf on 04 Apr 2016 22:26, edited 1 time in total.

Timberwolf
Engineer
Engineer
Posts: 86
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: [GS] Villages Is Villages

Post by Timberwolf »

OK - tried a few things.

Not having the compatibility script doesn't cause an issue for me in nightly r27510; I'd assume the same is true for OpenTTD 1.6

I tried different languages to see if that had any impact, but it's happy there for me.

In the folder you unpacked, do you have a lang/english.txt? It feels to me like the language file is missing - at least, the only way I could reproduce that message was by unpacking the .tar file and then removing the 'lang' folder.

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

Re: [GS] Villages Is Villages

Post by 3iff »

I tried the .tar file and the unpacked files via a folder.

The unpacked files have an english.txt file, contents are:

Code: Select all

STR_GROWTH_UNLIMITED :Cities have no growth limit{}
STR_GROWTH_OUTSTANDING :Growth prospects: {ORANGE}Outstanding{BLACK} {}
STR_GROWTH_EXCELLENT :Growth prospects: {ORANGE}Excellent{BLACK} {}
STR_GROWTH_VERYGOOD :Growth prospects: {ORANGE}Very Good{BLACK} {}
STR_GROWTH_GOOD :Growth prospects: {ORANGE}Good{BLACK} {}
STR_GROWTH_MEDIOCRE :Growth prospects: {ORANGE}Mediocre{BLACK} {}
STR_GROWTH_POOR :Growth prospects: {ORANGE}Poor{BLACK} {}
STR_GROWTH_VERYPOOR :Growth prospects: {ORANGE}Very Poor{BLACK} {}
STR_GROWTH_NONE :Growth prospects: {RED}None{BLACK} {}
STR_PASSENGER_SHORTFALL :Passenger shortfall: {RED}{NUM}{BLACK} {}
STR_MAIL_SHORTFALL :Mail shortfall: {RED}{NUM}{BLACK} {}
STR_PASSENGER_OK :Passenger shortfall: {ORANGE}{NUM}{BLACK} {}
STR_MAIL_OK :Mail shortfall: {ORANGE}{NUM}{BLACK}
STR_CONCAT_2 :{STRING}{STRING}
STR_CONCAT_3 :{STRING}{STRING1}{STRING1}
STR_CONCAT_4 :{STRING}{STRING}{STRING}{STRING}
folder contents are:
Clipboard01.png
Clipboard01.png (557.63 KiB) Viewed 6466 times
I'll try a few things in the meantime if I get an opportunity.

Thanks.

***

Solved? I just saw that you used V1.6.0. I'm currently using an earlier nightly (r27505). I'll try a current nightly and report back. I bet that might be the issue.

SOLVED:

My fault for the file extraction. I didn't put the english text into a lang folder...How did I miss that?

d0mi3l
Engineer
Engineer
Posts: 15
Joined: 16 Aug 2013 18:04
Location: Poland

Re: [GS] Villages Is Villages

Post by d0mi3l »

Can you tell me why my city dont grow?
Attachments
d3L-Tra, 1713-02-11.png
(916.29 KiB) Not downloaded yet

kotssmurf
Traffic Manager
Traffic Manager
Posts: 158
Joined: 27 May 2008 20:33

Re: [GS] Villages Is Villages

Post by kotssmurf »

This is a feature I have been waiting for since a long time now, I very much disliked the standard behavior of towns!
I haven't been able to play a lot since quiet some time now, but as soon as I have some spare time I will try this.

Timberwolf
Engineer
Engineer
Posts: 86
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: [GS] Villages Is Villages

Post by Timberwolf »

d0mi3l wrote:Can you tell me why my city dont grow?
The "Growth Prospects: None" line indicates that this city has hit its population limit, beyond which it won't grow unless you:

* Fund New Buildings with the local authority
* Deliver petroleum fuels, alcohol, food, goods or building materials (you may need to fund some accepting industries)

(In addition to the global limit, each town has its own individual population limit - the parameters just set the minimum and maximum range for this value. The "growth prospects" line tells you how close the town is to this limit without revealing it to the player outright.)

d0mi3l
Engineer
Engineer
Posts: 15
Joined: 16 Aug 2013 18:04
Location: Poland

Re: [GS] Villages Is Villages

Post by d0mi3l »

Could you adds some info about deliver goods, fuel, etc. or found new buildings to growth town in town window.

Timberwolf
Engineer
Engineer
Posts: 86
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: [GS] Villages Is Villages

Post by Timberwolf »

Yes, that's a good suggestion - it would make that mechanic more obvious if there's a context-sensitive message telling players what to do next in order to make the town grow.

Timberwolf
Engineer
Engineer
Posts: 86
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: [GS] Villages Is Villages

Post by Timberwolf »

I found a little bit of time this evening to hack on this, so town windows now display appropriate advice:

Image

And, if I add a few cargo trucks bringing goods to the town, the next option:

Image

Advice will always show the critical blocking issues of passengers and mail first, so hopefully will make the "what do I need to make this town grow?" question a little bit less opaque.

Update is on BaNaNaS, but for those who'd prefer a direct download I'll also attach it here.

btw, for any GS experts - I used "town cargo" as a generic, but is there a nice way to look up and display the translated actual cargo names given a cargo label (e.g. GOOD or PETR), so I can tell players exactly what they need to deliver without having to assume they're using a specific cargo set?
Attachments
Villages_Is_Villages-3.tar
(60 KiB) Downloaded 60 times

User avatar
Redirect Left
Tycoon
Tycoon
Posts: 6647
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: [GS] Villages Is Villages

Post by Redirect Left »

Timberwolf wrote:I found a little bit of time this evening to hack on this, so town windows now display appropriate advice:

Image

And, if I add a few cargo trucks bringing goods to the town, the next option:

Image

Advice will always show the critical blocking issues of passengers and mail first, so hopefully will make the "what do I need to make this town grow?" question a little bit less opaque.
That's a neat little idea, great work!
Image
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [GS] Villages Is Villages

Post by Zuu »

Timberwolf wrote:btw, for any GS experts - I used "town cargo" as a generic, but is there a nice way to look up and display the translated actual cargo names given a cargo label (e.g. GOOD or PETR), so I can tell players exactly what they need to deliver without having to assume they're using a specific cargo set?
If you only want to display the cargo human name without any amount, then use the {CARGO_LIST} string parameter. I don't remember exactly the details on what parameters it accept (eg. what bitshifts you can do to), but I looked up the most simple usage case from NoCarGoal for you.

Code: Select all

STR_GOAL_GLOBAL           :Help the world by achieving the goals for {WHITE}{CARGO_LIST}{ORANGE}, {WHITE}{CARGO_LIST}{ORANGE} and {WHITE}{CARGO_LIST}{ORANGE} before end of year {NUM}

Code: Select all

		local text = GSText(GSText.STR_GOAL_GLOBAL, 
				1 << this._cargo_list[0],
				1 << this._cargo_list[1],
				1 << this._cargo_list[2],
				this.GetEndYear() - 1);
		this._goal_list[0] = GSGoal.New(ALL_COMPANIES, text, GSGoal.GT_NONE, 0);
this._cargo_list[] is an array with the 3 goal cargoes.


If you want to include numbers, then you can just use {CARGO_TINY} or {CARGO_LONG} and pass first the cargo and second the count.

Oh.. and two hints. First, if you add strings, add them to the end of english.txt if you aim for save game compatibility. Eg allowing upgrade a old game to new version of GS. If you don't, then you can insert new strings anywhere in english.txt as you see fit. Second, a useful trick is that you can add a integer number to a string reference to get the next string in english.txt.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Timberwolf
Engineer
Engineer
Posts: 86
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: [GS] Villages Is Villages

Post by Timberwolf »

Excellent, thank you very much. I've made a small update so you now get shown the cargo which will have the biggest impact on town growth. New version on BaNaNaS and attached here.
Attachments
Villages_Is_Villages-4.tar
(60 KiB) Downloaded 49 times

Timberwolf
Engineer
Engineer
Posts: 86
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: [GS] Villages Is Villages

Post by Timberwolf »

And another small update... thanks to forum member SilverSurferZzZ, we now speak Spanish!

Image

Update attached and on BaNaNaS
Attachments
Villages_Is_Villages-5.tar
(60 KiB) Downloaded 56 times

xarick
Transport Coordinator
Transport Coordinator
Posts: 291
Joined: 26 Feb 2015 00:52

Re: [GS] Villages Is Villages

Post by xarick »

Code: Select all

dbg: [script] spanish:20: warning: STR_CONCAT_3: Param idx #1 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:20: warning: STR_CONCAT_3: Param idx #2 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:21: warning: STR_CONCAT_4: Param idx #1 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:21: warning: STR_CONCAT_4: Param idx #2 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:21: warning: STR_CONCAT_4: Param idx #3 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:20: warning: STR_CONCAT_3: Param idx #1 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:20: warning: STR_CONCAT_3: Param idx #2 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:21: warning: STR_CONCAT_4: Param idx #1 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:21: warning: STR_CONCAT_4: Param idx #2 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:21: warning: STR_CONCAT_4: Param idx #3 'STRING' doesn't match with template command 'STRING1'
I'm getting this in the debug console while I am using Villages Is Villages to test something for my patch.
Formerly known as Samu

User avatar
SilverSurferZzZ
Route Supervisor
Route Supervisor
Posts: 469
Joined: 29 Oct 2013 23:31

Re: [GS] Villages Is Villages

Post by SilverSurferZzZ »

Villages Is Villages 6, in spanish.
Villages Is Villages 6, in spanish.
VillagesIsVillages-00.PNG (19.08 KiB) Viewed 5270 times
Any patch that you apply to the game can create all kinds of problems ... I don't know what it could be.

For me, in normal OTTD (1.6.0), this script works fine. I hope that others can help you more.
NewGRFs__
City names/Landscape: Naruto | Planets | Lovers | Halloween | Kaijus
Vehicles: Famous Cars | Super Cars | Racing Cars | Cars Cars | Improved M Cars

SilverSurferZzZ has left the building!

xarick
Transport Coordinator
Transport Coordinator
Posts: 291
Joined: 26 Feb 2015 00:52

Re: [GS] Villages Is Villages

Post by xarick »

It happens in 1.6.0 too.

I'm starting OpenTTD as a dedicated server.

Code: Select all

dbg: [net] [core] starting network...
dbg: [net] [core] loading windows socket library
dbg: [net] [udp] initializing listeners
dbg: [net] [core] network online, multiplayer available
dbg: [net] Detected broadcast addresses:
dbg: [net] 0) 192.168.1.255
dbg: [net] [udp] closed listeners
dbg: [net] [udp] initializing listeners
dbg: [net] [udp] closed listeners
dbg: [net] [udp] initializing listeners
dbg: [net] starting listeners for clients
dbg: [net] [tcp] listening on IPv6 port [::]:3979 (IPv6)
dbg: [net] [tcp] listening on IPv4 port 0.0.0.0:3979 (IPv4)
dbg: [net] starting listeners for incoming server queries
dbg: [net] [udp] listening on IPv6 port [::]:3979 (IPv6)
dbg: [net] [udp] listening on IPv4 port 0.0.0.0:3979 (IPv4)
dbg: ogram Files\OpenTTD\baseset\D\a\\content_download\ai\lid:\Users\Ricardo\Documents\OpenTTD\content_download\aidbg: [net] Generating map, please wait...
dbg: [net] Map generation percentage complete: 5
dbg: [net] Map generation percentage complete: 10
dbg: [net] Map generation percentage complete: 15
dbg: [net] Map generation percentage complete: 20
dbg: [net] Map generation percentage complete: 25
dbg: [net] Map generation percentage complete: 30
dbg: [net] Map generation percentage complete: 35
dbg: [net] Map generation percentage complete: 40
dbg: [net] Map generation percentage complete: 45
dbg: [net] Map generation percentage complete: 50
dbg: [net] Map generation percentage complete: 55
dbg: [net] Map generation percentage complete: 60
dbg: [net] Map generation percentage complete: 65
dbg: [net] Map generation percentage complete: 70
dbg: [net] Map generation percentage complete: 75
dbg: [net] Map generation percentage complete: 80
dbg: [net] Map generation percentage complete: 85
dbg: [net] Map generation percentage complete: 90
dbg: [script] spanish:20: warning: STR_CONCAT_3: Param idx #1 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:20: warning: STR_CONCAT_3: Param idx #2 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:21: warning: STR_CONCAT_4: Param idx #1 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:21: warning: STR_CONCAT_4: Param idx #2 'STRING' doesn't match with template command 'STRING1'
dbg: [script] spanish:21: warning: STR_CONCAT_4: Param idx #3 'STRING' doesn't match with template command 'STRING1'
dbg: [net] Map generation percentage complete: 95
dbg: [net] Map generated, starting game
dbg: [net] [udp] received new session key from master server (IPv4)
ÔÇÄ*** Game paused (manual)
dbg: [net] [udp] advertising to master server
dbg: [net] [udp] queried from 94.23.161.41
dbg: [net] [udp] advertising on master server successful (IPv4)
dbg: [net] [udp] queried from 94.23.161.41
Formerly known as Samu

User avatar
SilverSurferZzZ
Route Supervisor
Route Supervisor
Posts: 469
Joined: 29 Oct 2013 23:31

Re: [GS] Villages Is Villages

Post by SilverSurferZzZ »

Code: Select all

STR_PASSENGER_OK :Passenger shortfall: {ORANGE}{NUM}{BLACK} {}
STR_MAIL_OK :Mail shortfall: {ORANGE}{NUM}{BLACK}
STR_CONCAT_2 :{STRING}{STRING}
STR_CONCAT_3 :{STRING}{STRING1}{STRING1}
STR_CONCAT_4 :{STRING}{STRING}{STRING}{STRING}
STR_CONCAT_2, STR_CONCAT_3 and STR_CONCAT_4 are a special strings... String inside string, and other and other inside... ... ...
Maybe your patch don't support them :(
NewGRFs__
City names/Landscape: Naruto | Planets | Lovers | Halloween | Kaijus
Vehicles: Famous Cars | Super Cars | Racing Cars | Cars Cars | Improved M Cars

SilverSurferZzZ has left the building!

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest