[GS] Technology Advancement

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

Post Reply
User avatar
Firrel
Engineer
Engineer
Posts: 118
Joined: 13 Aug 2019 17:06

[GS] Technology Advancement

Post by Firrel »

Technology Advancement GS

No longer maintained

Technology Advancement (TEAD) is a game script which changes the availability of technology: rail, road, water, air. The script allows to start at a certain technology year, slow down or speed up the technology advancement or unlock all technology. Supports any combination of NewGRF.

How the script works:
The way this script works is that the technology date is separated from the game date, so it can advance at different speed or be paused completely. Based on this date, new vehicles are released or old are
shelved.

See more in readme:
readme.txt
(4.67 KiB) Downloaded 322 times

Requirements:
  • OpenTTD version 1.10.x or newer
  • SuperLib v. 40
Download:
The first release (v0) is available on BaNaNaS. This might contain bugs, which I wait you to report, so you help me to make the script better

Limitations:
The game script is limited at the time of writing by these factors:
  • only vehicles can be enabled/disabled by game script
  • vehicle reliability is not relevant to technology date, using no breakdowns is almost mandatory
  • the game script cannot access model life parameter of vehicles, so a fixed model life has to be selected
  • the technology speed is modified in game script settings; story book buttons are currently worked on, which will allow better control over the speed
  • enabling new vehicles by game script command does not trigger new vehicle news

Updates:
Version 0 (2020/05/10):
- initial release
Attachments
TechnologyAdvancement-0.tar
(50.5 KiB) Downloaded 240 times
Last edited by Firrel on 11 Mar 2023 13:40, edited 1 time in total.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: [GS] Technology Advancement

Post by andythenorth »

This looks interesting, so I gave it a go.

First thing I did was use cheats to change game date, sorry :twisted:

Cheating date causes newgrf to introduce new vehicles, which the GS does then un-introduce again. :)
User avatar
Firrel
Engineer
Engineer
Posts: 118
Joined: 13 Aug 2019 17:06

Re: [GS] Technology Advancement

Post by Firrel »

andythenorth wrote: 06 Jun 2020 09:41 This looks interesting, so I gave it a go.

First thing I did was use cheats to change game date, sorry :twisted:

Cheating date causes newgrf to introduce new vehicles, which the GS does then un-introduce again. :)
Thank you for your feedback.

As I see it there are still too many issues to make this script work properly. I dont know if I will get to it or it will get shelved... I looked forward for the addition of changing engine availability and tried what can be done with it, but as I see it, there is still a long way for proper tech tree or daylength script.

As you say, the enabling/disabling is not working properly with cheating the year. I can make the techology date to not advance when the game year is cheated, which might solve it.

I finally checked the source code on how the engine enabling/disabling actually works and as it seems there is no way for this script to fully function as it is now (I may have missed something). The enable/disable will just force it to a state for the selected company, which can be then overriden by natural availability.
The engine could be disabled after it is released as the release date that can be acquired. But the natural disabling is dependant on engine reliability and model life, which are not available from game script. It would still be bothersome that a popup shows about new engine and it will just get disabled silently, confusing the player.
Checking engine availability in every loop can make the list always up to technology date. Issue is, disabling engine for a company will still return IsBuildable as true, so in every loop all disabled engines will be again disabled for each company. Disabling 13 engines takes 13 ticks, so 100 engines for 4 companies would take 400 ticks, which is too much.

The engine reliability is a whole other story. It is calculated per engine when it is naturally introduced, so releasing it early makes it almost unusable (50-60%). It would require to have the reliability calculated per engine per company, which would break the competition, because reliability is randomized.
User avatar
jfs
Tycoon
Tycoon
Posts: 1758
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: [GS] Technology Advancement

Post by jfs »

You're right, the way the availability is handled by OpenTTD probably needs more tweaks. It probably needs an additional bit for whether the availability has been overridden or not, and a way for the GS to reset the availability to "default".

A way to modify the max reliability curve for an engine could also be useful, but I'm sure if that was made available to GS, several NewGRF authors would cry foul ;)
klote
Engineer
Engineer
Posts: 2
Joined: 09 Mar 2023 23:20

Re: [GS] Technology Advancement

Post by klote »

Trying to load this script but i get this error
Image


Does any one know how to fix this error?
User avatar
Firrel
Engineer
Engineer
Posts: 118
Joined: 13 Aug 2019 17:06

Re: [GS] Technology Advancement

Post by Firrel »

klote wrote: 09 Mar 2023 23:23 Trying to load this script but i get this error
Image


Does any one know how to fix this error?
Most likely it was saved before initialization of the script could finished, which lead to empty save data and therefore missing `company_list` when loading it. Please try waiting for "Game setup done." logging message before saving the game if it solves the issue.

Here is the code snipped that could cause it. Changing the {} to null should prevent this issue.

Code: Select all

// In case (auto-)save happens before we have initialized all data,
// save the raw _loaded_data if available or an empty table.
if (!this._init_done) {
	return this._loaded_data != null ? this._loaded_data : {};
}
If you need to get this game loading, you can add load data validation into loading of the GS like this:

Code: Select all

Log.Info("Loading data from savegame made with version " + version + " of the game script", Log.LVL_INFO);

if (!tbl.rawin("technology_date") || !tbl.rawin("company_list")) {
	Log.Warning("Incorrect format of saved data, restarting game script", Log.LVL_INFO);
	this._loaded_data = null;
	return;
}
As this approach to slowing/speeding up tech progression is not really working well due to many limitations, I am not planning on continuing its development. There is a well working solution of changing day lenght in JGR patch pack or try supporting 2TallTyler's efforts bringing it to vanilla OpenTTD.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 13 guests