Game scripts in loaded game.

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
zlavick
Engineer
Engineer
Posts: 3
Joined: 06 Jan 2014 19:53

Game scripts in loaded game.

Post by zlavick »

Is there any chance to load game scripts in loaded game?

Situation: I've started game in dedicated server with citybuilder script, but after server's crashing the saved game starts without citybuilder script.

Maybe there is some way to manage game scripts like AI scripts (startai/stopai)?

UPD: Hmm. It works only when i save game as admin (via rcon command). But if i save game via simple client - it doesn't save game scripts into ".sav" file.
I have no correct save-file, so my question is still actual.
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Game scripts in loaded game.

Post by krinn »

Can't do, while AI are start as new company, no company exist for the GS.

A proposed fix that will comes out is that even crashed, the GS name (or its md5) in use will be record in the savegame. So it will try to load the GS everytime you load the game.
That's for case when user save game after the GS has crashed.

Didn't knew you could also loose it by saving with client, even it looks logic as the GS run on the server.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Game scripts in loaded game.

Post by Zuu »

zlavick wrote:UPD: Hmm. It works only when i save game as admin (via rcon command). But if i save game via simple client - it doesn't save game scripts into ".sav" file.
I have no correct save-file, so my question is still actual.
The Game Script run only on the server. Thus the clients do not have access to the internal data of the Game Script (and does not even know which GS if any that is running) and can therefore not save the data needed to load the game with the GS. Thus you must save the game on the server and not from a client.

If you only have a client save, then you already have lost this data.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
zlavick
Engineer
Engineer
Posts: 3
Joined: 06 Jan 2014 19:53

Re: Game scripts in loaded game.

Post by zlavick »

Thank you, Zuu.

Didn't know that and didn't saw this info in manuals.

Now saving games the way you have said.

And one more question. Will it be possible in future to manage GS data remotely, for example download\reload scripts via rcon commands right in a game?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Game scripts in loaded game.

Post by Zuu »

You can already via rcon download GS from bananas if that is what you were asking for: http://wiki.openttd.org/Dedicated_serve ... ne_content

Reloading of GS scripts is currently not supported neither in single player nor multiplayer. Personally I don't have any plans on working on code changes to change that. It might not be very hard to to implement as for AIs. However Game Scripts get a quite large portion of computation power after world generation, but before the game starts. This will probably be harder to add so that scripts get this also when reloaded. The size of this "bonus" is quite large and allows most scripts to initialize all towns etc. with custom rules before the game starts.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
zlavick
Engineer
Engineer
Posts: 3
Joined: 06 Jan 2014 19:53

Re: Game scripts in loaded game.

Post by zlavick »

Everything is clear now.

Thank you for so detailed answer.
ST2
Engineer
Engineer
Posts: 63
Joined: 07 Apr 2011 14:17

Re: Game scripts in loaded game.

Post by ST2 »

My latest tests lead me to this conclusions, using a rcon save and a rcon load, dedicated server side:
- Server will ignore what GameScript was being used on the used .cfg file;
- Server will ignore what was the settings on [game_scripts], the same .cfg file;
- Server will load ALL stuff on "main.nut", but doesn't care of .cfg file - what works is what's on "info.nut";

As known, when loading a game, in "main.nut" Gamescript referenced files/settings, are taken the first ones, ignoring any conditions there, and "openttd.cfg" [game_scripts] isn't loaded at all, getting the default ones, defined on the file "info.nut"!

Most people won't notice this, and haven't said a word!
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Ahrefs [Bot] and 14 guests