[GS] RCG - A city growth GameScript for OTTD

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

aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: [GS] RCG - A new city growth GS for OTTD/FIRS

Post by aantono »

Just tried the r39 and getting the following error: "Your script made an error: "STR_TOWNBOX_NOGROWTH" does not exist"

I also tried to take out all the GRF, thinking that it might be something to do with them, but even with an empty list, get the same error.

I am using OpenTTD version 1.4.2

Update: I think I narrowed it down to the defect in the tar - the language files are not being put in the /lang directory, which causes the error.
Unnamed, 1st Jan 1952.png
(186.27 KiB) Downloaded 7 times
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] RCG - A new city growth GS for OTTD/FIRS

Post by keoz »

aantono wrote:Just tried the r39 and getting the following error: "Your script made an error: "STR_TOWNBOX_NOGROWTH" does not exist"
Hello,

thank you for reporting this. Indeed, there was a bug in the utils which I use to build releases.

It's fixed now. You can find the corrected version on the release topic (updated to r41).

Also note that last revisions use GS SuperLib v. 38, downloadable on Bananas.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: [GS] RCG - A new city growth GS for OTTD

Post by aantono »

Thanks for the quick fix.

One question - is it possible to add a config property to indicate if the "Growth: xxx days" addition to the town sign should be visible or hidden? It makes the town area overwhelmed with text, especially if you happen to have a station right on the town tile, then you have the town name, the station name and the growth info all overlapping on the same area and make it cluttered and unreadable. :(
Gigigonzalez
Engineer
Engineer
Posts: 91
Joined: 12 Jun 2014 14:24

Re: [GS] RCG - A new city growth GS for OTTD

Post by Gigigonzalez »

Is this script able to renew buildings? Im using another city builder script which is unable to do so.
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: [GS] RCG - A new city growth GS for OTTD

Post by aantono »

Gigigonzalez wrote:Is this script able to renew buildings? Im using another city builder script which is unable to do so.
What exactly do you mean by that?
Gigigonzalez
Engineer
Engineer
Posts: 91
Joined: 12 Jun 2014 14:24

Re: [GS] RCG - A new city growth GS for OTTD

Post by Gigigonzalez »

aantono wrote:
Gigigonzalez wrote:Is this script able to renew buildings? Im using another city builder script which is unable to do so.
What exactly do you mean by that?
Quite literally, is this script able to demolish and renew buildings, like with original growth, old buildings often get replaced by newer ones as years go by.

We use aphid's city builder script and he says there is no 'reliable' way for the script to demolish buildings (to make room for new ones)
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] RCG - A new city growth GS for OTTD

Post by keoz »

aantono wrote:
Gigigonzalez wrote:Is this script able to renew buildings? Im using another city builder script which is unable to do so.
What exactly do you mean by that?
Some scripts trigger town growth using a function (GSTown.ExpandTown()) which is not adapted to the purpose, because it only builds new buildings, but doesn't handle renewing (destruction/reconstruction of houses, which allows new buildings to appear). The result is that if you're using some GRF which has different time eras for houses (like TTRS), all the buildings are stuck in old times. In RCG there is not this problem, because the script does not builds houses by itself, but just redefines the town growth rate, using GSTown.SetGrowthRate().

So, to put it simple: yes, buildings are (also) renewed.
aantono wrote:One question - is it possible to add a config property to indicate if the "Growth: xxx days" addition to the town sign should be visible or hidden? It makes the town area overwhelmed with text, especially if you happen to have a station right on the town tile, then you have the town name, the station name and the growth info all overlapping on the same area and make it cluttered and unreadable. :(
Yes, it is possible. And actually, I find that it is an interesting idea. I'll put that in my todo-list for a next release. I'll not add the feature for the moment, because I'd like to test and publish the actual version for now.

But waiting for the next changes, you can manage it simply by yourself, by a simple hack: just comment out (which means: add "//" in front of the lines) the corresponding part in the file town.nut (you will see the change when reloading a savegame):

Code: Select all

//	local sign_text = TownSignText();
//	if (this.label_sign_id == -1) {
//		this.label_sign_id = GSSign.BuildSign(GSTown.GetLocation(this.id), sign_text);
//	} else {
//		if (GSSign.IsValidSign(this.label_sign_id)) {
//			GSSign.SetName(this.label_sign_id, sign_text);
//		} else {
//			this.label_sign_id = GSSign.BuildSign(GSTown.GetLocation(this.id), sign_text);
//		}
//	}
As a side note, I just checked out and the monthly updates are 25% faster without town signs. I'm quite surprised !
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: [GS] RCG - A new city growth GS for OTTD

Post by krinn »

You makes things complex.

Code: Select all

if (GSSign.IsValidSign(this.label_sign_id))	GSSign.SetName(this.label_sign_id, sign_text);
								else		this.label_sign_id = GSSign.BuildSign(GSTown.GetLocation(this.id), sign_text);
As long as this.label_sign_id != null you'll be fine, and you seems to use -1 as default/no sign value.
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] RCG - A new city growth GS for OTTD

Post by keoz »

krinn wrote:You makes things complex.

Code: Select all

if (GSSign.IsValidSign(this.label_sign_id))	GSSign.SetName(this.label_sign_id, sign_text);
								else		this.label_sign_id = GSSign.BuildSign(GSTown.GetLocation(this.id), sign_text);
As long as this.label_sign_id != null you'll be fine, and you seems to use -1 as default/no sign value.
Indeed. You're right, there's one useless check on label_sign_id. I'll change that.

Following the original code, I use -1 and not null because if I check IsValidSign() on a null sign_id, the script crashes and complains because it wants an integer.

Related to this, I'm also thinking that I should get rid of the ClearAllSigns() call, performed during the init phase. After all, there is no reason that the saved signs aren't valid after reloading the game. And I already noted that building signs takes a huge amount of time (something like one tick per sign ?)

Edit: both changes done in r49 (here [edit: no more] attached). 50 ticks saved on initialisation due to removing ClearAllSigns() \o/ (1024*1024 map, with 50 monitored towns atm).
Last edited by keoz on 21 Aug 2014 12:18, edited 1 time in total.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] RCG - A new city growth GS for OTTD

Post by keoz »

I made some graphics and explanations about calculations internals, for who is actually wondering what has to be expected from the script about town growing.

They are presented in the repository's wiki, which you can consult there: http://dev.openttdcoop.org/projects/gs-rcg/wiki/Wiki

Hoping that everything is clear and, from a specialized mathematical-lexical POV, correct (I'm historian, not mathematician). :mrgreen:

Additional note: I just noticed a bug on signs, which is fixed now. I also removed some heavy initializing stuff, which revealed as unnecessary. Savegame loading is really fast now (6 ticks on a 1024*1024 map). Should be bug free, but only fast tested.
Last edited by keoz on 22 Aug 2014 19:40, edited 1 time in total.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] RCG - A new city growth GS for OTTD

Post by keoz »

About savegame compatibility when using RCG

Some of you may have been a little bit disappointed by the fact that sometime, subsequent revisions weren't compatible between them, which means that changing your RCG revision caused savegames to crash on loading. That was generally caused by changes in saved data.

Hence I just decided to introduce a method allowing further revisions to be compatible between them. This allows to update your script in ongoing games, without starting a new one. The loading might take some extra time, because the script needs to reset some datas. Check in the AI/Gamescript log for the end of initialization.

If there are any problems with updates, just tell me and I see what can be done.

Please, report bugs. Going for version 3 now (I want it clean :D ).
Last edited by keoz on 24 Aug 2014 16:49, edited 2 times in total.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
CreepyD
Engineer
Engineer
Posts: 2
Joined: 22 Aug 2014 19:51

Re: [GS] RCG - A new city growth GS for OTTD

Post by CreepyD »

Any idea what's gone wrong here?
I've been trying for aaaages to get it working but it just looks messy / has no colours.
Just downloaded r59 and superlib 38.

Look forward to using this great looking mod :)

Added:
Nevermind, just got r62 and it's working now! lol
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] RCG - A new city growth GS for OTTD

Post by keoz »

That's strange. Did you eventually use any other script in this game before loading RCG ? IIRC, some of the strings that I see there never existed in my script. (The upper part. The lower is mine).

Edit: ok, fine. I have just seen your edited message.

Edit bis: Here the last revision -r72 (updated 24/8).
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] RCG - A city growth GameScript for OTTD

Post by keoz »

After some last bugfixes and testing ...

Version 4 is ready now.

Changes:
- added support for baseset industries (temperate, arctic, tropical,
toyland), all FIRS' economies and ECS (all vectors)
- introducing GSText and lang files
- townboxes text formatting improved
- added a method to check savegame compatibility between revisions
- savegame code completely rewritten and simplified
- code cleanup and additional comments
- readme.txt completely rewritten
- updated to SuperLib v. 38
- setting up hg repository
- fix: game is no more crashing when new towns are founded. Thanks to
krinn.
- fix: game is no more crashing when saving immediately after loading
- fix: the script now correctly counts the deliveries from all
companies
- fix: lot of bugs and even better ... No more known bugs.

Note: you can safely switch from either last revisions, either last versions, just by downloading the new version from BaNaNas. When reloading the game, it may take some extra time for initialisation, to reset some data. Also note that the (included) readme has been completely rewritten, so that you can find more detailed explanations there.

Thanks a lot to:
- planetmaker, Zuu for their help
- specially krinn, who suggested a lot of code improvments !

EDIT. I Spot out a problem when loading from old version. It's normally solved in last uploaded version. If someone has problems to reload savegames, complain here.
EDIT2. Looks like OTTD really doesn't like minor GS version numbers. Version 4 then.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
lugo
Engineer
Engineer
Posts: 100
Joined: 12 Oct 2010 13:55

Re: [GS] RCG - A city growth GameScript for OTTD

Post by lugo »

Hi, thank you for your nice script!

Would it be possible to make the categories optional?
I really like the concept of those categories,
but i would like to leave out category 4 in my game.

Edit:

i don't know if that is already planned, but what about a story book page explaining the categories?
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: [GS] RCG - A city growth GameScript for OTTD

Post by aantono »

Upgraded the script (use hg to pull from trunk), reloaded the game to get the new version initialized and got this error:
Total Transport, 9th Jul 1949.png
(207.91 KiB) Downloaded 1 time
Edit: After the error, I've saved the game again, then reloaded it, and after a month the script reset itself without any visible errors.
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] RCG - A city growth GameScript for OTTD

Post by keoz »

lugo wrote:Hi, thank you for your nice script!
I'm glad you like :)
lugo wrote:Would it be possible to make the categories optional?
I really like the concept of those categories,
but i would like to leave out category 4 in my game.

i don't know if that is already planned, but what about a story book page explaining the categories?
About proposal 1: that'd be a non trivial change. I am still thinking about the possibility of simplifying categories (maybee by giving the choice between 3 or 5 categories). It is not impossible that further changes in this direction also leads to the possibility of just removing a category, but all of this will take some time and reflexion.

About proposal 2: that's already on the top of my TODO list and I'm right working on it.
aantono wrote:Upgraded the script (use hg to pull from trunk), reloaded the game to get the new version initialized and got this error:
Total Transport, 9th Jul 1949.png
Edit: After the error, I've saved the game again, then reloaded it, and after a month the script reset itself without any visible errors.
Today I made a lot of changes in development version for including new features and last revisions are potentially quite unstable. Could you eventually post a savegame ?
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: [GS] RCG - A city growth GameScript for OTTD

Post by aantono »

keoz wrote: Today I made a lot of changes in development version for including new features and last revisions are potentially quite unstable. Could you tell me what revision did you use ?
Output of hg log is this:

Code: Select all

changeset:   84:921db6d25d7c
tag:         tip
user:        keoz
date:        Sat Aug 30 15:55:29 2014 +0200
summary:     Introducing a bunch of expert settings for finetuning.
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] RCG - A city growth GameScript for OTTD

Post by keoz »

aantono wrote:Output of hg log is this:[...]
Could you eventually post the savegame ? (the one of 1949-06-19, which is gonna 11 days later).
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: [GS] RCG - A city growth GameScript for OTTD

Post by aantono »

There you go.
Attachments
Total Transport, 19th Jun 1949.sav
(179.83 KiB) Downloaded 137 times
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests