Adonthell
0.4
|
00001 /* 00002 $Id: mapviewschedules.dxt,v 1.1 2001/10/15 15:00:06 gnurou Exp $ 00003 00004 Copyright (C) 2001 Alexandre Courbot 00005 Part of the Adonthell Project http://adonthell.linuxgames.com 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License. 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY. 00011 00012 See the COPYING file for more details. 00013 */ 00014 00015 /*! 00016 00017 \page page9 Writing mapview schedules 00018 00019 \section mviewsched0 The Basics 00020 A mapview schedule file should always be placed into the \e 00021 script/schedules/mapviews directory in the %game hierarchy. It 00022 should consist of a single class, named like the module itself. 00023 A schedule is attached to a mapview by using the 00024 mapview::set_schedule () method. See it's documentation for more 00025 details. You should be particularly careful that the argument 00026 list given to mapview::set_schedule () \e has to be a Python 00027 tuple containing ONLY Python strings or integers. 00028 00029 \section mviewsched1 Arguments passed to __init__ () 00030 When you call mapview::set_schedule (), the first argument 00031 passed to the class constructor is a reference to the mapview 00032 that called this method. This parameter should be saved as it will 00033 most likely be used during the run () method to control the 00034 mapcharacter. Then follows the arguments stored in the Python 00035 tuple that has (optionally) been passed to mapview::set_schedule (). 00036 00037 \section mviewsched2 Arguments passed to run () 00038 No arguments are passed to the run () method. 00039 00040 \section mviewsched3 Structure of a mapview schedule file 00041 Here is what a mapcharacter schedule file should ideally look like: 00042 \verbatim 00043 # 00044 # (C) Copyright <year> <your name> 00045 # Part of the Adonthell Project http://adonthell.linuxgames.com 00046 # 00047 # This program is free software; you can redistribute it and/or modify 00048 # it under the terms of the GNU General Public License. 00049 # This program is distributed in the hope that it will be useful, 00050 # but WITHOUT ANY WARRANTY. 00051 # 00052 # See the COPYING file for more details 00053 # 00054 00055 # 00056 # <description of the schedule> 00057 # 00058 00059 <do your imports here> 00060 00061 class myschedule: 00062 00063 # Parameters: 00064 # Description of myparameter1 00065 # Description of myparameter2 00066 def __init__ (self, mapviewinstance, myparameter1, myparameter2): 00067 self.myself = mapviewinstance 00068 <do you other initialisation here> 00069 00070 def run (self): 00071 <mapcharacter control> 00072 00073 def __del__ (self) 00074 <eventual cleanup> 00075 \endverbatim 00076 00077 \section mviewsched4 Storing variables 00078 It is unsafe to use class variables different from those that are 00079 passed to the __init__ method. When a mapview's schedule is 00080 state-saved, only the schedule filename and it's initialisation 00081 arguments (the Python tuple passed to mapview::set_schedule ()) 00082 are saved. So, if you create class variables inside the object, 00083 do not expect them to survive %game saving/loading. However, 00084 mapview schedules usually don't need persistant variables. 00085 */