From cafbdf720e72c0b7024817670f4d0f5fec32b922 Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 1 May 2009 15:56:19 +0000 Subject: [PATCH] Minor typo-fixes as well as making some variable names more intuitive. --- game/gamesrc/commands/examples/state_example.py | 14 ++++++++++---- src/objects/models.py | 11 +++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/game/gamesrc/commands/examples/state_example.py b/game/gamesrc/commands/examples/state_example.py index a574b202e3..d3f8cc68b6 100644 --- a/game/gamesrc/commands/examples/state_example.py +++ b/game/gamesrc/commands/examples/state_example.py @@ -48,7 +48,10 @@ def cmd_entermenu(command): #get the player object calling the command source_object = command.source_object #this is important: we use the set_state() command - #to shift the player into a state named 'menu'. + #to shift the player into a state named 'menu'. Other useful + #access functions on source_object are get_state() + # and clear_state(), the latter returns the player to + # the normal mode of gameplay. source_object.set_state(STATENAME) #display the menu. print_menu(source_object) @@ -59,13 +62,15 @@ def cmd_entermenu(command): # can be read as help entries when in the menu. # def menu_cmd_option1(command): - """option1 + """ + option1 This selects the first option. """ source_object = command.source_object print_menu(source_object, 1) def menu_cmd_option2(command): - """option2 + """ + option2 This selects the second option. Duh. <> @@ -74,7 +79,8 @@ def menu_cmd_option2(command): source_object = command.source_object print_menu(source_object, 2) def menu_cmd_clear(command): - """clear + """ + clear Clears the options. """ source_object = command.source_object diff --git a/src/objects/models.py b/src/objects/models.py index a77d69d06d..612bcd3dc1 100755 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -985,18 +985,21 @@ class Object(models.Model): otype = int(self.type) return defines_global.OBJECT_TYPES[otype][1][0] + #state access functions - def get_state(self): + def get_state(self): return self.state - def set_state(self, cmd_table=None): + def set_state(self, state_name=None): """ - Set the state by defining which cmd_table is currently used. + Only allow setting a state on a player object, otherwise + fail silently. """ if self.is_player(): - self.state = cmd_table + self.state = state_name def clear_state(self): + "Set to no state (return to normal operation)" self.state = None