Loading
#openttdcoop - Paste
Archives
Trending
Docs
Login
ABAP
ActionScript
ActionScript 3
Ada
AIMMS3
ALGOL 68
Apache configuration
AppleScript
Apt sources
ARM ASSEMBLER
ASM
ASP
asymptote
Autoconf
Autohotkey
AutoIt
AviSynth
awk
BASCOM AVR
Bash
Basic4GL
BibTeX
BlitzBasic
bnf
Boo
Brainfuck
C
C#
C (LoadRunner)
C (Mac)
C (WinAPI)
C++
C++ (Qt)
C++ (WinAPI)
CAD DCL
CAD Lisp
CFDG
ChaiScript
Chapel
CIL
Clojure
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
Dart
DCL
DCPU-16 Assembly
DCS
Delphi
Diff
DIV
DOS
dot
E
ECMAScript
Eiffel
eMail (mbox)
EPC
Erlang
Euphoria
EZT
F#
Falcon
FO (abas-ERP)
Formula One
Fortran
FreeBasic
FreeSWITCH
GADV 4CS
GAMBAS
GDB
genero
Genie
glSlang
GML
GNU/Octave
GNU Gettext
GNU make
Gnuplot
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML
HTML5
Icon
INI
Inno
INTERCAL
Io
ISPF Panel
J
Java
Java(TM) 2 Platform Standard Edition 5.0
Javascript
JCL
jQuery
KiXtart
KLone C
KLone C++
LaTeX
LDIF
Liberty BASIC
Lisp
LLVM Intermediate Representation
Locomotive Basic
Logtalk
LOLcode
Lotus Notes @Formulas
LotusScript
LScript
LSL2
Lua
MagikSF
MapBasic
Matlab M
Microchip Assembler
Microsoft Registry
mIRC Scripting
MMIX
Modula-2
Modula-3
MOS 6502 (6510) ACME Cross Assembler format
MOS 6502 (6510) Kick Assembler format
MOS 6502 (6510) TASM/64TASS 1.46 Assembler format
Motorola 68000 - HiSoft Devpac ST 2 Assembler format
Motorola 68000 Assembler
MXML
MySQL
Nagios
NetRexx
newlisp
nginx
Nimrod
NML NewGRF Meta Language
NSIS
Oberon-2
Objeck Programming Language
Objective-C
OCaml
OCaml (brief)
ooRexx
OpenBSD Packet Filter
OpenOffice.org Basic
Oracle 8 SQL
Oracle 11 SQL
Oxygene
OZ
ParaSail
PARI/GP
Pascal
PCRE
per
Perl
Perl 6
PHP
PHP (brief)
PIC16
Pike
Pixel Bender 1.0
PL/I
PL/SQL
PostgreSQL
PostScript
POVRAY
PowerBuilder
PowerShell
ProFTPd configuration
Progress
Prolog
PROPERTIES
ProvideX
Puppet
PureBasic
Python
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
R / S+
Racket
Rails
RBScript
REBOL
rexx
robots.txt
RPM Specification File
Ruby
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
Squirrel Script
Squirrel Script with OpenTTD AI/GS
StandardML
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term Macro
Text
thinBasic
TypoScript
Unicon (Unified Extended Dialect of Icon)
Uno Idl
Unreal Script
UPC
Urbi
Vala
vb.net
VBScript
Vedit macro language
Verilog
VHDL
Vim Script
Visual Basic
Visual Fox Pro
Visual Prolog
Whitespace
Whois (RPSL format)
Winbatch
X++
XBasic
XML
Xorg configuration
YAML
ZiLOG Z80 Assembler
ZXBasic
Index: src/script/api/script_controller.hpp =================================================================== --- src/script/api/script_controller.hpp (revision 27110) +++ src/script/api/script_controller.hpp (working copy) @@ -18,8 +18,26 @@ /** * The Controller, the class each Script should extend. It creates the Script, - * makes sure the logic kicks in correctly, and that GetTick() has a valid + * makes sure the logic kicks in correctly, and that #GetTick() has a valid * value. + * + * When starting a new game, or when loading a game, OpenTTD tries to match a + * script that matches to the specified version as close as possible. It tries + * (from first to last, stopping as soon as the attempt succeeds) + * + * - load the exact same version of the same script, + * - load the latest version of the same script that supports loading data from + * the saved version (the version of saved data must be equal or greater + * than ScriptInfo::MinVersionToLoad), + * - load the latest version of the same script (ignoring version requirements), + * - (for AIs) load a random AI, and finally + * - (for AIs) load the dummy AI. + * + * If a script was found, an instance is constructed of the class derived from ScriptController. + * If there is script data available in the loaded game, #Load is called with the data. + * Finally, #Start is called to start execution of the script. + * See also http://wiki.openttd.org/AI:Save/Load for more details. + * * @api ai game */ class ScriptController { @@ -46,7 +64,49 @@ */ void Start(); +#ifdef DOXYGEN_API /** + * Save the state of the script. + * + * By implementing this function, you can store some data inside the savegame. + * The function should return a table with the information you want to store. + * You can only store: + * + * - integers, + * - strings, + * - arrays (max. 25 levels deep), + * - tables (max. 25 levels deep), + * - booleans, and + * - nulls. + * + * In particular, instances of classes can't be saved including + * ScriptList. Such a list should be converted to an array or table on + * save and converted back on load. + * + * The function is called as soon as the user saves the game, + * independently of other activities of the script. The script is not + * notified of the call. To avoid race-conditions between #Save and the + * other script code, change variables directly after a #Sleep, it is + * very unlikely, to get interrupted at that point in the execution. + * See also http://wiki.openttd.org/AI:Save/Load for more details. + * + * @note No other information is saved than the table returned by #Save. + * For example all pending events are lost as soon as the game is loaded. + * + * @return Data of the script that should be stored in the save game. + */ + SquirrelTable Save(); + + /** + * Load saved data just before calling #Start. + * The function is only called when there is data to load. + * @param version Version number of the script that created the \a data. + * @param data Data that was saved (return value of #Save). + */ + void Load(int version, SquirrelTable data); +#endif /* DOXYGEN_API */ + + /** * Find at which tick your script currently is. * @return returns the current tick. */
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever