• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

mapcharschedules.dxt

00001 /*
00002    $Id: mapcharschedules.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 page8 Writing mapcharacter schedules
00018 
00019 \section mcharsched0 Generalities
00020 A mapcharacter schedule file should always be placed in the \e
00021 script/schedules/mapcharacters directory in the %game hierarchy. It
00022 should contain a single class, named like the module. A schedule is
00023 attached to a mapcharacter by the mapcharacter::set_schedule ()
00024 method. See it's documentation for more details. You should be
00025 particularly careful that the argument list given to
00026 mapcharacter::set_schedule () \e has to be a Python tuple
00027 containing ONLY Python strings or integers.
00028 
00029 \section mcharsched1 Arguments passed to __init__ ()
00030 When you call mapcharacter::set_schedule (), the first argument
00031 passed to the class constructor is a reference to the mapcharacter
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 follow the arguments inside the tuple (optionally)
00035 passed to mapcharacter::set_schedule ().
00036 
00037 \section mcharsched2 Arguments passed to run ()
00038 No arguments are passed to the run () method.
00039 
00040 \section mcharsched3 Structure of a mapcharacter 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, mapcharacterinstance, myparameter1, myparameter2):
00067         self.myself = mapcharacterinstance
00068         <do your other initialisation here>
00069 
00070     def run (self):
00071         <mapcharacter control>
00072 
00073     def __del__ (self)
00074         <eventual cleanup>
00075 \endverbatim
00076 
00077 \section mcharsched4 Storing variables
00078 It is unsafe to store variables in the class instance others than
00079 those passed to the __init__ method. When a mapcharacter's
00080 schedule is state-saved, only the schedule filename and it's
00081 initialisation arguments (the Python tuple passed to
00082 mapcharacter::set_schedule ()) are saved. So, if you create variables
00083 in the \e self object, do not expect them to survive %game
00084 saving/loading. A safe approach is to make use of the storage class,
00085 from which mapcharacter inherits, to store your persistant variables.
00086 Then they are automatically saved together with the mapcharacter.
00087 
00088 */

Generated on Fri Mar 18 2011 for Adonthell by  doxygen 1.7.1