1
0
Fork 0
OpenTTD is an open source simulation game based upon Transport Tycoon Deluxe
 
 
 
 
 
Go to file
Michal Charemza dc26e40704
Add: [Console] schedule command to execute a script file later
The change in https://github.com/OpenTTD/OpenTTD/pull/10655, released as part
of OpenTTD 14, changed how auto saving works from every X amount of game time,
to every X amount of real time. This is an improvement for normal play, but
there are cases where saving every X amount of game time is useful. For example
when developing and comparing AIs, or using OpenTTD to conduct experiments such
as via https://github.com/michalc/OpenTTDLab which extracts data from savegame
files.

This change adds a general "schedule" console command that makes it possible
for a console script to be scheduled for the future, where that script can, for
example, contain a "save" command to save the game. That script can also then
reschedule itself or another script, and thus making it possible to re-create
the pre-OpenTTD 14 behaviour of saving the game every X amount of game time.
(Possibly with a whole "suite" of game scripts that call each other in a chain,
each of them hard coded with a different filename to allow all the savegames to
be saved with different names, but that's a doable detail)

The current change only allows scheduling "on-next-calendar-month", since that
is my specific use case, but the syntax is hopefully friendly to this being
extended in the future. And by scheduling any console script, it is much more
general and so hopefully useful than just for saving games.

There was some discussion on what this should be called at
https://discord.com/channels/142724111502802944/1008473233844097104/1247278039927361546
(as well as some issues with an alternatively proposed solution using game
scripts at https://github.com/OpenTTD/OpenTTD/pull/12750). Instead of
"schedule", "trigger" was suggested for something to only be called once, but
after writing code and output to the user, it didn't make it immediately clear
that "trigger" means "once at some point in the future", and seemed too close
to "exec". Also I think "schedule" can be used _both_ for one-off or repeated
events in the future (in English it's common to say to "schedule an
appointment", even if it's just the one).

Or code-wise:

schedule on-next-calendar-month my.scr (the only current behaviour)
schedule every-calendar-month my.scr (possible future behaviour?)
schedule "* 1 * *" my.scr (possible future cron-like behaviour?)

Possible future extensions could include some mechanism for cancelling
something that has been scheduled, and I have no reason to think that mechanism
would be different for something scheduled to repeat or just as a one-off, so I
think also it makes sense to that we would have the one command for both.

The new "schedule" command:

- Only allows a single script to be scheduled - any (correct) usage of the
  "schedule" command will overwrite the previous, but hopefully the console
  messages make this clear
- Only allows a script to be scheduled once at the start of next month (but
  this could be extended if useful).
- Does not offer a way to unschedule, but hopefully since the script can only
  be scheduled to run once in the future, and relatively close in the future
  (at the start of next month), this shouldn't be too much of an annoying missing
  feature.

Co-authored-by: Patric Stout <github@truebrain.nl>
2024-07-01 09:51:38 +01:00
.github Codefix: [CI] dubious ownership for emscripten 2024-06-26 23:02:27 +02:00
bin Codechange: We are heading to 15 2024-02-18 21:48:54 +01:00
cmake Codefix: [Win32] Use correct range for version in rc file 2024-06-26 23:02:27 +02:00
docs Change: Add variable ground types for road waypoints 2024-06-24 22:12:08 +02:00
media Add: Road waypoint default graphics 2024-06-24 22:12:08 +02:00
os Add: Use macOS Game Mode identification (#12700) 2024-05-25 09:19:41 -04:00
regression Change: Use per-company group numbers. (#12297) 2024-05-07 19:01:28 +00:00
src Add: [Console] schedule command to execute a script file later 2024-07-01 09:51:38 +01:00
.dorpsgek.yml Codechange: [CI] build some targets every night, instead of every PR 2024-03-11 15:44:30 +01:00
.editorconfig Cleanup: Remove BOM/ZWNBSP in the middle of .editorconfig (#10860) 2023-05-23 12:49:47 +02:00
.gitignore Change: add vcpkg.json to instruct vcpkg what dependencies we require 2023-12-30 18:40:04 +01:00
CMakeLists.txt Doc: Add Apache 2.0 licensing info for CheckAtomic.cmake (#12603) 2024-05-02 15:13:00 +02:00
CODINGSTYLE.md Doc: Explain comment alignment in CODINGSTYLE.md 2024-06-15 17:13:42 -04:00
COMPILING.md Doc: Updated Visual Studio, cpp standard and Cmake version 2024-04-15 23:06:23 +02:00
CONTRIBUTING.md Doc: Fix broken links in COMPILING and CONTRIBUTING guides (#11608) 2023-12-20 03:15:15 +01:00
COPYING.md Doc: Add more hyperlinks within the included documentation (#11288) 2023-09-11 18:55:23 +00:00
CPackProperties.cmake.in Add: create bundles via CPack 2020-06-05 19:36:05 +02:00
CREDITS.md Update: Developer credits (#12235) (#12235) 2024-03-08 18:31:58 +01:00
Doxyfile.in Update: Doxyfiles to doxygen 1.9.4 2024-05-10 13:17:19 +01:00
README.md Doc: Add Apache 2.0 licensing info for CheckAtomic.cmake (#12603) 2024-05-02 15:13:00 +02:00
changelog.txt Doc: Prepare for 14.0-beta3 release (#12018) 2024-02-06 21:48:07 +01:00
known-bugs.txt Doc: Remove resolved issue #4415 from known-bugs.txt (#12773) 2024-06-11 11:35:10 -04:00
vcpkg.json Change: add vcpkg.json to instruct vcpkg what dependencies we require 2023-12-30 18:40:04 +01:00

README.md

OpenTTD

Table of contents

1.0) About

OpenTTD is a transport simulation game based upon the popular game Transport Tycoon Deluxe, written by Chris Sawyer. It attempts to mimic the original game as closely as possible while extending it with new features.

OpenTTD is licensed under the GNU General Public License version 2.0, but includes some 3rd party software under different licenses. See the section "Licensing" below for details.

1.1) Downloading OpenTTD

OpenTTD can be downloaded from the official OpenTTD website.

Both 'stable' and 'nightly' versions are available for download:

  • most people should choose the 'stable' version, as this has been more extensively tested
  • the 'nightly' version includes the latest changes and features, but may sometimes be less reliable

OpenTTD is also available for free on Steam, GOG.com, and the Microsoft Store. On some platforms OpenTTD will be available via your OS package manager or a similar service.

1.2) OpenTTD gameplay manual

OpenTTD has a community-maintained wiki, including a gameplay manual and tips.

1.3) Supported platforms

OpenTTD has been ported to several platforms and operating systems.

The currently supported platforms are:

  • Linux (SDL (OpenGL and non-OpenGL))
  • macOS (universal) (Cocoa)
  • Windows (Win32 GDI / OpenGL)

Other platforms may also work (in particular various BSD systems), but we don't actively test or maintain these.

1.3.1) Legacy support

Platforms, languages and compilers change. We'll keep support going on old platforms as long as someone is interested in supporting them, except where it means the project can't move forward to keep up with language and compiler features.

We guarantee that every revision of OpenTTD will be able to load savegames from every older revision (excepting where the savegame is corrupt). Please report a bug if you find a save that doesn't load.

1.4) Installing and running OpenTTD

OpenTTD is usually straightforward to install, but for more help the wiki includes an installation guide.

OpenTTD needs some additional graphics and sound files to run.

For some platforms these will be downloaded during the installation process if required.

For some platforms, you will need to refer to the installation guide.

1.4.1) Free graphics and sound files

The free data files, split into OpenGFX for graphics, OpenSFX for sounds and OpenMSX for music can be found at:

Please follow the readme of these packages about the installation procedure. The Windows installer can optionally download and install these packages.

1.4.2) Original Transport Tycoon Deluxe graphics and sound files

If you want to play with the original Transport Tycoon Deluxe data files you have to copy the data files from the CD-ROM into the baseset/ directory. It does not matter whether you copy them from the DOS or Windows version of Transport Tycoon Deluxe. The Windows install can optionally copy these files.

You need to copy the following files:

  • sample.cat
  • trg1r.grf or TRG1.GRF
  • trgcr.grf or TRGC.GRF
  • trghr.grf or TRGH.GRF
  • trgir.grf or TRGI.GRF
  • trgtr.grf or TRGT.GRF

1.4.3) Original Transport Tycoon Deluxe music

If you want the Transport Tycoon Deluxe music, copy the appropriate files from the original game into the baseset folder.

  • TTD for Windows: All files in the gm/ folder (gm_tt00.gm up to gm_tt21.gm)
  • TTD for DOS: The GM.CAT file
  • Transport Tycoon Original: The GM.CAT file, but rename it to GM-TTO.CAT

1.5) Add-on content / mods

OpenTTD features multiple types of add-on content, which modify gameplay in different ways.

Most types of add-on content can be downloaded within OpenTTD via the 'Check Online Content' button in the main menu.

Add-on content can also be installed manually, but that's more complicated; the OpenTTD wiki may offer help with that, or the OpenTTD directory structure guide.

1.5.1) Social Integration

OpenTTD has the ability to load plugins to integrate with Social Platforms like Steam, Discord, etc.

To enable such integration, the plugin for the specific platform has to be downloaded and stored in the social_integration folder.

See OpenTTD's website, under Downloads, for what plugins are available.

1.6) OpenTTD directories

OpenTTD uses its own directory structure to store game data, add-on content etc.

For more information, see the directory structure guide.

1.7) Compiling OpenTTD

If you want to compile OpenTTD from source, instructions can be found in COMPILING.md.

2.0) Contact and Community

'Official' channels

'Unofficial' channels

2.1) Multiplayer games

You can play OpenTTD with others, either cooperatively or competitively.

See the multiplayer documentation for more details.

2.2) Contributing to OpenTTD

We welcome contributors to OpenTTD. More information for contributors can be found in CONTRIBUTING.md

2.3) Reporting bugs

Good bug reports are very helpful. We have a guide to reporting bugs to help with this.

Desyncs in multiplayer are complex to debug and report (some software development skils are required). Instructions can be found in debugging and reporting desyncs.

2.4) Translating

OpenTTD is translated into many languages. Translations are added and updated via the online translation tool.

3.0) Licensing

OpenTTD is licensed under the GNU General Public License version 2.0. For the complete license text, see the file 'COPYING.md'. This license applies to all files in this distribution, except as noted below.

The squirrel implementation in src/3rdparty/squirrel is licensed under the Zlib license. See src/3rdparty/squirrel/COPYRIGHT for the complete license text.

The md5 implementation in src/3rdparty/md5 is licensed under the Zlib license. See the comments in the source files in src/3rdparty/md5 for the complete license text.

The fmt implementation in src/3rdparty/fmt is licensed under the MIT license. See src/3rdparty/fmt/LICENSE.rst for the complete license text.

The nlohmann json implementation in src/3rdparty/nlohmann is licensed under the MIT license. See src/3rdparty/nlohmann/LICENSE.MIT for the complete license text.

The OpenGL API in src/3rdparty/opengl is licensed under the MIT license. See src/3rdparty/opengl/khrplatform.h for the complete license text.

The catch2 implementation in src/3rdparty/catch2 is licensed under the Boost Software License, Version 1.0. See src/3rdparty/catch2/LICENSE.txt for the complete license text.

The icu scriptrun implementation in src/3rdparty/icu is licensed under the Unicode license. See src/3rdparty/icu/LICENSE for the complete license text.

The monocypher implementation in src/3rdparty/monocypher is licensed under the 2-clause BSD and CC-0 license. See src/3rdparty/monocypher/LICENSE.md for the complete license text.

The OpenTTD Social Integration API in src/3rdparty/openttd_social_integration_api is licensed under the MIT license. See src/3rdparty/openttd_social_integration_api/LICENSE for the complete license text.

The atomic datatype support detection in cmake/3rdparty/llvm/CheckAtomic.cmake is licensed under the Apache 2.0 license. See cmake/3rdparty/llvm/LICENSE.txt for the complete license text.

4.0 Credits

See CREDITS.md