4 Copyright (C) 2001 Alexandre Courbot
5 Part of the Adonthell Project http://adonthell.linuxgames.com
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY.
12 See the COPYING file for more details.
17 \page page8 Writing mapcharacter schedules
19 \section mcharsched0 Generalities
20 A mapcharacter schedule file should always be placed in the \e
21 script/schedules/mapcharacters directory in the %game hierarchy. It
22 should contain a single class, named like the module. A schedule is
23 attached to a mapcharacter by the mapcharacter::set_schedule ()
24 method. See it's documentation for more details. You should be
25 particularly careful that the argument list given to
26 mapcharacter::set_schedule () \e has to be a Python tuple
27 containing ONLY Python strings or integers.
29 \section mcharsched1 Arguments passed to __init__ ()
30 When you call mapcharacter::set_schedule (), the first argument
31 passed to the class constructor is a reference to the mapcharacter
32 that called this method. This parameter should be saved as it will
33 most likely be used during the run () method to control the
34 mapcharacter. Then follow the arguments inside the tuple (optionally)
35 passed to mapcharacter::set_schedule ().
37 \section mcharsched2 Arguments passed to run ()
38 No arguments are passed to the run () method.
40 \section mcharsched3 Structure of a mapcharacter schedule file
41 Here is what a mapcharacter schedule file should ideally look like:
44 # (C) Copyright <year> <your name>
45 # Part of the Adonthell Project http://adonthell.linuxgames.com
47 # This program is free software; you can redistribute it and/or modify
48 # it under the terms of the GNU General Public License.
49 # This program is distributed in the hope that it will be useful,
50 # but WITHOUT ANY WARRANTY.
52 # See the COPYING file for more details
56 # <description of the schedule>
59 <do your imports here>
64 # Description of myparameter1
65 # Description of myparameter2
66 def __init__ (self, mapcharacterinstance, myparameter1, myparameter2):
67 self.myself = mapcharacterinstance
68 <do your other initialisation here>
71 <mapcharacter control>
77 \section mcharsched4 Storing variables
78 It is unsafe to store variables in the class instance others than
79 those passed to the __init__ method. When a mapcharacter's
80 schedule is state-saved, only the schedule filename and it's
81 initialisation arguments (the Python tuple passed to
82 mapcharacter::set_schedule ()) are saved. So, if you create variables
83 in the \e self object, do not expect them to survive %game
84 saving/loading. A safe approach is to make use of the storage class,
85 from which mapcharacter inherits, to store your persistant variables.
86 Then they are automatically saved together with the mapcharacter.