[GS] Simple City Builder game script

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

Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

[GS] Simple City Builder game script

Post by Honza_ »

Novapolis team presenting:

Simple City Builder script

1. Claim a town by placing company headquaters
2. Deliver cargos and grow the town to the biggest population ever seen

Features
- When configured towns will require more cargos to grow
- Displays requirements in Town window and Goal window
- simulates the original OpenTTD growth mechanism

Settings
- spawning of some industries
- storage of delivered cargos
- Requirements, population at which cargo is required and storage decay of each cargo (up to 32 if defined, ECS and FIRS supported of course)
- pausing game on start in multiplayer
- place signs to mark cities
- place signs to mark claimed towns
- dynamic change of town growth
- limiting cities size

Future plans
- add more growth mechanics


== OVERVIEW ==
Settings
Settings
simplecb_settings.png (42.98 KiB) Viewed 9965 times
simplecb_gui.png
Various gui details
(540.4 KiB) Downloaded 1 time
simplecb_town.png
Various gui details
(365.92 KiB) Downloaded 1 time

Available via game content or here for manual install http://bananas.openttd.org/en/gs/

Enjoy


Source code repositories

GITHUB : https://github.com/TheDude-gh/simplecb (active)

OpenTTDcoop devzone : https://dev.openttdcoop.org/projects/citybuilder-gs (deprecated)



== TRANSLATIONS ==
Global access for translations is enabled in openttdcoop Web translator. If anyone wishes kindly to contribute translation in any language, you can do so at:

https://translator.openttdcoop.org/proj ... builder-gs

If it does not let you, you will probably need to sign up as traslator here

https://translator.openttdcoop.org/



== UPDATES ==

On 25.08.2021
Version 13
=FIXES=
- Prevent duplicate companies in scores. Could happen playing scenarios.

=CHANGES=
Town skrinking - new optional setting
- When town is not supplied properly, it has a chance of demolishing house and decreasing population
- town will shrink on condition any cargo is supplied less then 25% of requirement and population is less than 500

City Population Limit setting
- now cities can be limited by population percentage of biggest town instead of its multiplication. Range is 0 to 1000% instead of previous multiplier 1 to 10.

Changing settings in running game
- now you can change any setting in running game so no need to start from beggining when you are not happy with some setting.
- You can do this by changing setting in game (SHIFT+F12 or whatever hotkey you set), saving the game and on load the new settings will update.

================
On 17.04.2021
Version 12
=CHANGES=
Languages updated
- industry cargo sets presets
- support new 64 cargo limit
- one change in language file, and project url
- warning messages with WARN flag
- visual code reformatting
- change of default values of some settings
- demolition function preparation


================
On 11.11.2017
Version 11
=CHANGES=
Languages updated


On 04.10.2015 - new version
Language updates.

On 12.01.2015 - new version
Setting for limiting City population to maximum twice the biggest town
Maximum Goal Progress lines limited to 24
New languages
Added YETI cargos description to settings menu
Dynamic growth interval is changeable now and disabling it works
Fixes plural forms in english and czech language

On 11.05.2014 - new version
Fixed missing declaration
Fixed some bad calculations
Fixed some bad conditions
Fixed misspells in czech.lng

On 07.05.2014 - new version
Town::Service function is no more in bad scope, causing troubles.

On 27.04.2014 - new version
On bananas - changelog included
- Fixed save load crash bug

On 26.04.2014 - new version
On bananas - changelog included
- New growth style, funding buildings, storybook and more

On 08.11.2013 - new version
On bananas - changelog included

On 10.11.2013 - new version
Fixes some silly things of previous version
Last edited by Honza_ on 03 Sep 2021 23:11, edited 14 times in total.
User avatar
Phreeze
Director
Director
Posts: 514
Joined: 12 Feb 2010 14:30
Location: Luxembourg

Re: [GS] Simple City Builder game script

Post by Phreeze »

does it work on single player too ?

(can't test atm, so i'm asking ;) )
fabca2
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 14 Apr 2004 15:18
Location: Fr

Re: [GS] Simple City Builder game script

Post by fabca2 »

Hello,
I translated this nice script into french.
I could not perform any test, once I place french.txt on lang folder I have a message telling me that STR_GLOBAL_GOAL_CB does not exist, which is wrong of course.

This is well known when translated file is not in UTF8 format (see for example http://www.tt-forums.net/viewtopic.php? ... e#p1069046)

But this is not the case, file is UTF8 encoded.
And even worth, if I just copy english.txt into whatever.txt without even opening the file, I got exactly the same message!

It looks strange to me, I suppose it's not a bug (I'm using stable 1.3.2) it's probably something I didn't understood...
That's a little bit frustrating, it's my first translation attempt, if someone can help me.
Thank you.

whatever, I attached the file, it may works for you ?
Attachments
french.txt
the translated file (utf8)
(5.67 KiB) Downloaded 908 times
Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

Re: [GS] Simple City Builder game script

Post by Honza_ »

hi,
most likely you have some mistake in the file. When you remove the french.txt from lang folder, the script works. Unforunately AI console is not very helpful when looking for language file problem as far as I know.

You can locate the problem by removing some lines randomly and see if the error still appears.
fabca2
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 14 Apr 2004 15:18
Location: Fr

Re: [GS] Simple City Builder game script

Post by fabca2 »

hi,
Honza_ wrote:hi,
most likely you have some mistake in the file. When you remove the french.txt from lang folder, the script works....
it could be, but I think you didn't paid attention to this :
fabca2 wrote:And even worth, if I just copy english.txt into whatever.txt without even opening the file, I got exactly the same message!
Which means, the file itself is probably not the only one culpit.
The test I made (after ruining 2 hours) : I totally remove my file, I just copy your english.txt into another file name (give the name you want, italian.txt french.txt dutch.txt or whatever.txt) run the game, create a new game.. crash.

Can you check on our PC if it behave the same ?
Thanks.
Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

Re: [GS] Simple City Builder game script

Post by Honza_ »

the script as it is on bananas works well. When I add your french.txt it crashes. => fix your french.txt

If you rename english.txt so there is no english.txt, I guess it wont work since english.txt is likely required always
fabca2
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 14 Apr 2004 15:18
Location: Fr

Re: [GS] Simple City Builder game script

Post by fabca2 »

Honza_ wrote:If you rename english.txt so there is no english.txt, I guess it wont work since english.txt is likely required always
But did you try to COPY your english.txt into another language (without even opening it) ?
Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

Re: [GS] Simple City Builder game script

Post by Honza_ »

Problem is in your translation with STRINGx formats.
Study those

http://wiki.openttd.org/OpenTTDDevBlack ... al_strings

http://wiki.openttd.org/Format_of_langfiles
Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

Re: [GS] Simple City Builder game script

Post by Honza_ »

New version.
See first post.
juhawp
Engineer
Engineer
Posts: 1
Joined: 18 Nov 2013 15:02

Re: [GS] Simple City Builder game script

Post by juhawp »

HI!

Sorry I'm new to this so these questions might sound stupid.

How can I deliver for example coal to the city (it doesn't accept it).

And what does "ECS and FIRS" mean?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [GS] Simple City Builder game script

Post by planetmaker »

juhawp wrote:HI!

Sorry I'm new to this so these questions might sound stupid.

How can I deliver for example coal to the city (it doesn't accept it).

And what does "ECS and FIRS" mean?
You deliver coal to a city by delivering it to a power plant (or other industry) in the city's influence area which accepts it
ECS and FIRS are both NewGRFs which change industries (quite a lot).
Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

Re: [GS] Simple City Builder game script

Post by Honza_ »

New version with new 1.4 features.
See first post.
User avatar
dirace
Engineer
Engineer
Posts: 27
Joined: 29 Jan 2010 11:39

Re: [GS] Simple City Builder game script

Post by dirace »

hi,
I load the GS in a multiplayer server, and I feed the town all the requirments, but the town did not grow at all, do I miss some configuration?
and at the same time, the storage page shows different info for different player, only the 1st player show complete info for town growing.
problem.png
problem.png (236.02 KiB) Viewed 9973 times
problem2.png
problem2.png (50.95 KiB) Viewed 9973 times
acabin
Engineer
Engineer
Posts: 27
Joined: 05 Mar 2009 18:40

Re: [GS] Simple City Builder game script

Post by acabin »

dirace wrote:hi,
I load the GS in a multiplayer server, and I feed the town all the requirments, but the town did not grow at all, do I miss some configuration?
and at the same time, the storage page shows different info for different player, only the 1st player show complete info for town growing.
problem.png
problem2.png
It seems there is something wrong with town.nut:

function Town::Service() is included by function Town::Grow(growmech)

move Service() out from Grow() will fix the problem.
I speak Chinglish...
Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

Re: [GS] Simple City Builder game script

Post by Honza_ »

Hi,
thanks for info. The Town::Service definition should indeed be outside the other function.

Even so, there is one known OpenTTD problem, when Normal grow mechanism is selected, in cases when town does not grow because of missing transport service, the script will make false statement that town grows even when town is not, because there is no API in game script to recongnize this.

But I guess this was not your problem.
acabin
Engineer
Engineer
Posts: 27
Joined: 05 Mar 2009 18:40

Re: [GS] Simple City Builder game script

Post by acabin »

There is another bug:

When a player got the goal, the script will hang up at goalprogress.nut:29:

Code: Select all

			if(checkgamelength >= this.game_length) txt = GSText.STR_WINNER_TIME;
And it should be:

Code: Select all

			local txt;
			if(checkgamelength >= this.game_length) txt = GSText.STR_WINNER_TIME;
I speak Chinglish...
Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

Re: [GS] Simple City Builder game script

Post by Honza_ »

Thanks. It should be ok. Looking forward for next bug report :-)
Ozgarb
Engineer
Engineer
Posts: 4
Joined: 15 May 2014 13:57

Re: [GS] Simple City Builder game script

Post by Ozgarb »

World creator has a problem. Towns are very close together and less populated town is city.
Attachments
Example...
Example...
Ekran Alıntısı.PNG (386.29 KiB) Viewed 9969 times
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [GS] Simple City Builder game script

Post by planetmaker »

Ozgarb wrote:World creator has a problem. Towns are very close together and less populated town is city.
Honestly, I see no issue here, just randomness at work:

Both, placement and size is randomly distributed. Distance to other towns has a minimum value as does the town or city size in terms of houses which are *tried* to be generated. Cities are not necessarily the biggest towns around at the start of map creation, they can have a *tendency* to be bigger, but again, that multiplicator is applied to the random size, thus the end result may still be small. However, cities will grow faster later on, if they receive an equal level of service compared to a 'normal' town.

Also, your issue most likely is unrelated to the game script here most likely.
Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

Re: [GS] Simple City Builder game script

Post by Honza_ »

Indeed, nothing GS can do abou that.

Ozgarb, if you want map generator with more possibilities, suggest new feature on flyspray ;-)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 6 guests